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?

Was it helpful?

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
scroll top