Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert 64bit Binary to Long equivalent

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.

like image 227
washtik Avatar asked Apr 21 '10 14:04

washtik


People also ask

What is the binary equivalent of 64?

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).

How to Convert decimal to 64 bit binary?

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.


1 Answers

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);
like image 190
zaf Avatar answered Oct 07 '22 21:10

zaf