Skip to content

Instantly share code, notes, and snippets.

@nakov
Created October 26, 2020 13:39
Show Gist options
  • Save nakov/be9a3d301faa8216217e9fe9382ee5c4 to your computer and use it in GitHub Desktop.
Save nakov/be9a3d301faa8216217e9fe9382ee5c4 to your computer and use it in GitHub Desktop.
using System;
class Program
{
static void Main()
{
long num = 2882400063;
string result = "";
while (num > 0)
{
long d = num % 16;
result = GetHexDigit(d) + result;
num = num / 16;
}
Console.WriteLine(result);
}
private static string GetHexDigit(long d)
{
if (d < 10)
return "" + d;
else if (d == 10)
return "A";
else if (d == 11)
return "B";
else if (d == 12)
return "C";
else if (d == 13)
return "D";
else if (d == 14)
return "E";
else if (d == 15)
return "F";
else
throw new Exception("Invalid digit");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment