Skip to content
Advertisement

How to convert list array to float

I have an little endian list value in python, I get with serial line.

I get this value as a byte like this:

JavaScript

How can I convert this 4 byte (little endian) value to float ?

Advertisement

Answer

If the float is in IEEE754 format (which it very likely is), you can convert your list of numbers to a byte array and then use struct.unpack to unpack it:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement