Skip to content

Instantly share code, notes, and snippets.

@jakesays-old
Last active December 10, 2015 00:48
Show Gist options
  • Select an option

  • Save jakesays-old/6130941d86eb09fbe9bd to your computer and use it in GitHub Desktop.

Select an option

Save jakesays-old/6130941d86eb09fbe9bd to your computer and use it in GitHub Desktop.
Octal converter
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