[erlang-questions] OTP float error on ARM

Mikael Pettersson mikpe@REDACTED
Wed Oct 15 14:39:33 CEST 2008


Bob Ippolito writes:
 > There's code in io_lib_format.erl that does the default format floats,
 > which assumes IEEE 754 floats. Perhaps the float<->binary code is
 > broken on your platform, or your platform doesn't do IEEE 754?
 > 
 > This is the code in io_lib_format (in R12B3 anyway, I don't have R12B4
 > installed on this machine):
 > 
 > mantissa_exponent(F) ->
 >     case <<F:64/float>> of
 >         <<_S:1, 0:11, M:52>> -> % denormalized
 >             E = log2floor(M),
 >             {M bsl (53 - E), E - 52 - 1075};
 >         <<_S:1, BE:11, M:52>> when BE < 2047 ->
 >             {M + ?BIG_POW, BE - 1075}
 >     end.
 > 
 > Does the output for this differ in your shell? If so, then your Erlang
 > VM isn't doing the right thing when converting floats to binary...
 > 
 > 1> <<1.0:64/float>>.
 > <<63,240,0,0,0,0,0,0>>

Off-hand I can't say if that code above is compatible with ARM's
more "exotic" FP formats, like the insane FPA format.
(Big-endian even on little-endian machines, or something like that.)

What I can say is that R12 built natively with a softfloat VFP
toolchain works for me on both big- and little-endian machines.

Q1. Is the target machine big or little endian?
Q2. What's the FP format? hard or soft? FPA or VFP?
    Or something else like Maverick?



More information about the erlang-questions mailing list