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?
views:
219answers:
1
+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
2010-01-20 09:50:42
Thanks for that :)And BinaryReader is gonna be very useful too.
izb
2010-01-20 10:01:49
@izb: By the way, be careful about endianness issues that might arise.
Mehrdad Afshari
2010-01-20 10:03:14