How do I read 64-bit IEEE Standard 754 double-precision numbers from binary data?
-
21-09-2019 - |
Question
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?
Solution
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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow