[erlang-questions] OTP float error on ARM
Bob Ippolito
bob@REDACTED
Wed Oct 15 12:23:59 CEST 2008
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>>
2008/10/15 WS Dao <chn.dao77@REDACTED>:
> I cross-compiled OTP R12B4 for my ARM9 platform (S3C2410, kernel 2.4.18)
> When I run erl on arm, float error occurs:
> # ./erl
> Eshell V5.6.4 (abort with ^G)
> 1> 3+5.
> 8
> 2> 3.0.
> 0.
> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005307579804
> 3> 3.0+4.0.
> 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000531405562
> 4>
>
> My toolchain is gcc 3.4.5. I'd wrote a c test program and cross-compile it,
> no float problems found.
>
> Any suggestion?
>
>
> -dao
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list