We have something like:
float f = 1234.5678F;
Let's pretend the binary representation of this is 0x1234ABCD
. How can I get the value 305441741
(==0x1234ABCD
) from f
?
We have something like:
float f = 1234.5678F;
Let's pretend the binary representation of this is 0x1234ABCD
. How can I get the value 305441741
(==0x1234ABCD
) from f
?
BitConverter class should help you.
Something like this:
float f = 1234.5678F;
var bytes = BitConverter.GetBytes(f);
var result = string.Format("0x{0:x}{1:x}{2:x}{3:x}", bytes[0], bytes[1], bytes[2], bytes[3]);