views:

219

answers:

1

I have a stream of data which consists of 64-bit IEEE standard 754 floating point numbers. How would I read these as doubles in using C#? Is there a way to convert a long/ulong into a double?

+3  A: 

BitConverter.Int64BitsToDouble method is specifically designed to do this. Alternatively, you can use a BinaryReader on top of the stream and take double values directly with its ReadDouble method.

double doubleValue = BitConverter.Int64BitsToDouble(longValue);
Mehrdad Afshari
Thanks for that :)And BinaryReader is gonna be very useful too.
izb
@izb: By the way, be careful about endianness issues that might arise.
Mehrdad Afshari