Created
October 26, 2020 13:39
-
-
Save nakov/be9a3d301faa8216217e9fe9382ee5c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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