Problem with 64 bit FP under ARM

Martin Sandiford ms@REDACTED
Sat Aug 23 05:35:04 CEST 2003


Hello all,

I have a problem with 64 bit floating point numbers on an embedded
SA1110 based machine running under Linux.

A summary of the problem:

(Running under Linux on x86):
1> <<1.0:64/float>>.
<<63,240,0,0,0,0,0,0>>
(Pretty much as expected for a little endian machine)

(Running under Linux on ARM):
1> <<1.0:64/float>>.
<<0,0,0,0,63,240,0,0>>
(Looks a bit like little endian, only the quads are swapped)

This essentially means that any code compiled with floating point
constants in it will not run on the other machine. It might also mean
other issues as well, but this is where I first discovered the
problem.

I'm not an ARM expert, so I can only assume that the correct
representation for a double on ARM is with the quads swapped with
respect to "normal" LE ordering.  Does anyone here know if this is the
case?  I'm thinking it maybe could be a problem with the FP emulator?
(There is no FPU on this board).

In the mean time, I've included some hacks in erl_bits.c to modify
erts_bs_put_float() and erts_bs_get_float() to swap the quad order when
reading or writing 64 bit floats on ARM.  This seems to fix the cross
compilation problem.  Are there any other areas that I should be looking
at?

Martin



More information about the erlang-questions mailing list