Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Have a device that when polled returns answer as four 8 bit bytes that together (32 bits) represent a single precision floating point number.
How can I easily convert the four 8 bit bytes to a float?

What I have tried:

Have a routine that examines the four 8 bit bytes bit by bit, does the crazy math to convert it to a single precision float. Computations get crazy. Seems there must be an easier way.
Posted
Updated 4-Aug-17 6:53am
Comments
BillWoodruff 4-Aug-17 17:39pm    
if your whatever .NET flavor doesn't provide the BitConverter library, see:

c# - How do I convert an array of floats to a byte[] and back? - Stack Overflow[^]
Patrice T 4-Aug-17 18:37pm    
Show your routine that do the crazy math.

1 solution

 
Share this answer
 
Comments
BillWoodruff 4-Aug-17 17:38pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900