Last active
December 10, 2015 00:48
-
-
Save jakesays-old/6130941d86eb09fbe9bd to your computer and use it in GitHub Desktop.
Octal converter
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
| ulong x = 289; | |
| char[] octalDigits = { '0', '1', '2', '3', '4', '5', '6', '7'}; | |
| var sb = new StringBuilder(); | |
| ulong digitIndex; | |
| while (x > 0) | |
| { | |
| digitIndex = x % 8; | |
| x = x / 8; | |
| sb.Append(octalDigits[digitIndex]); | |
| } | |
| Console.WriteLine(new string(sb.ToString().Reverse().ToArray())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment