[erlang-questions] OTP float error on ARM
WS Dao
chn.dao77@REDACTED
Thu Oct 16 05:59:13 CEST 2008
my shell output is:
4> <<1.0:64/float>>.
<<0,0,0,0,63,240,0,0>>
as Tony said, S3C2410/ARM920T CPU , double float is "Middle Endian"
IEEE float: 12 34 AB CD
Middle Endian: AB CD 12 34
my toolchain doesn't support "-msoft-float" option.
[root@REDACTED ~]# arm-unknown-linux-gnu-readelf -h
/tmp/cross-compile/lib/erlang/erts-5.6.4/bin/beam
ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x21f84
Start of program headers: 52 (bytes into file)
Start of section headers: 1346104 (bytes into file)
Flags: 0x2, has entry point, GNU EABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 31
Section header string table index: 28
My platform doesn't support clock_gettime(CLOCK_MONOTONIC,&ts) ,
/erts/emulator/sys/unix/sys.c, so I can't use debian binary.
2008/10/15 Bob Ippolito <bob@REDACTED>
> 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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081016/378db94a/attachment.htm>
More information about the erlang-questions
mailing list