Have you checked for endianness? Erlang assumes big-endian-arranged bytes when extracting floats the way you are doing it.
Demo:
bin = <<:math.pi()::float-32>> <> <<0, 0, 0>>
<<64, 73, 15, 219, 0, 0, 0>>
<<x::float-32, rest::binary>> = bin
<<64, 73, 15, 219, 0, 0, 0>>
x
3.1415927410125732
<<x::big-float-32, rest::binary>> = bin
<<64, 73, 15, 219, 0, 0, 0>>
x
3.1415927410125732
<<x::little-float-32, rest::binary>> = bin
<<64, 73, 15, 219, 0, 0, 0>>
x
-4.03314608963584e16
As you can see, by default big endian is used. So if your values are little-endian-arranged, you have to specify that explicitly.
In your example, try changing float-size(32) to little-float-size(32) and see if it works.


















