Reputation: 565
When I launch this console application I get 0
, instead of 32 bit string. It throws no error, however.
static void Main()
{
double num = 2.75;
byte [] bytes = BitConverter.GetBytes(num);
int toInt = BitConverter.ToInt32(bytes, 0);
string bitString = Convert.ToString(toInt);
Console.WriteLine(bitString);
}
Upvotes: 1
Views: 55
Reputation: 887897
double
is 64 bits.
You're looking at the top 32 bits, which are all zero.
You want float
(or call ToInt64
to see all of the bits).
Upvotes: 2