How do i convert a value given as a hexadecimal string to an Octal format, when the number is too large to fit in a 64 bits number?
I currently convert a byte array to hex like this
Byte[] data = { 116, 4, 228, 18, 189, 145, 31, 7, 123, 74, 174, 151, 54, 144, 224, 49, 210, 169, 43, 213 };
hex = BitConverter.ToString(data).Replace("-", string.Empty);
Output in Hex:
7404E412BD911F077B4AAE973690E031D2A92BD5
How do I get the Octal representation?
So i tried this earlier, but it doesn't work.
string binaryval = "";
binaryval = Convert.ToString(Convert.ToInt32(hexValue,16), 8);
foreach (char ch in hexValue)
{
binaryval += Convert.ToString(Convert.ToInt32(ch.ToString(), 16), 8);
}
0xFFis0377(octal), you'll need to do more than taking two characters and converting them.2BD5in Windows Calc, you'll see25725. This is not equal to your53325. Remember, three hex nibbles (FFF) equal four octal nibbles (7777). You tried it with two nibbles (FF) which leave you a rest value (377).