How can we convert the following 64 bit binary into the long equivalent;
01111101 10100011 01001111 11111111 11111111 11111111 11111111 11000000
equals 7D A3 4F FF FF FF FF C0 HEX
equals 9053167636875050944 << this is the value we want in a C# variable
EDIT: The large binary number is currently stored as a String. So its a string to long conversion that I am looking for.
64 in binary is 1000000. Unlike the decimal number system where we use the digits 0 to 9 to represent a number, in a binary system, we use only 2 digits that are 0 and 1 (bits).
An easy method of converting decimal to binary number equivalents is to write down the decimal number and to continually divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero. So for example. Convert the decimal number 29410 into its binary number equivalent.
Here you go: http://msdn.microsoft.com/en-us/library/system.convert.toint64.aspx
And examples here: http://www.csharphelp.com/2007/09/converting-between-binary-and-decimal-in-c/
Specifically (where bin is a 'binary' string):
long l = Convert.ToInt64(bin,2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With