[erlang-questions] Floating point conversion problem on big endian architecture

Matthias Lang matthias@REDACTED
Mon Apr 11 07:00:58 CEST 2011


Hi,

Mikael has already answered in general terms. I want to add a specific
counter-example. I cross-compile on x86 to arm, here's what I get:

# uname -a
Linux gth 2.6.36-07957-gb1adc07 #10 Mon Mar 21 14:27:41 CET 2011 armv5tejl GNU/Linux
# erl
Erlang R14B01 (erts-5.8.2) [source] [rq:1] [async-threads:0] [kernel-poll:false] 

Eshell V5.8.2  (abort with ^G)
1> B = <<3.2:32/big-float>>, io:format("~w~n", [B]).
<<64,76,204,205>>
ok
2> <<R:32/big-float>> = B, R.
3.200000047683716

The erl-xcomp-armle-linux-gnu.conf I use is the same as the MIPS one
included with R14B01, apart from one line:

  erl_xcomp_host=arm-linux

Matt

----------------------------------------------------------------------

On Thursday, April 07, Stefan Hudelmaier wrote:
> Hi,
> 
> we're cross compiling Erlang/OTP on a x86 PC for ARM. On the
> resulting runtime on ARM we have the following strange problem:
> Converting float to binary seems to work fine, exactly as on x86:
> 
> > B = <<3.2:32/big-float>>.
> > io:format("~w~n", [B]).
> <<64,76,204,205>>
> 
> But converting back to float from this binary, yields the wrong
> result on ARM:
> 
> > <<R:32/big-float>> = B.
> > R.
> -428443648.0
> 
> While on x86, it works as expected:
> 
> > <<R:32/big-float>> = B.
> > R.
> 3.200000047683716
> 
> When compiling for ARM, we have set erl_xcomp_bigendian=yes. hipe is
> disabled. We have tried R14A and R14B02.
> 
> Please let me know, if there is any more information we need to provide.
> 
> Kind regards,
> Stefan



More information about the erlang-questions mailing list