[erlang-bugs] Rounding errors with hipe

Fredrik Svahn fredrik.svahn@REDACTED
Tue Dec 2 23:28:37 CET 2008


I get rounding errors for some odd cases when running one of the programs in
the Computer Language Shootout with Hipe. So far I have only seen it on
32-bit (x86) targets.

I am guessing this might be a known problem/limitation in Hipe. I have
however not seen any previous bug reports on it, so better safe than sorry;
Here is a minimal test program with different results for byte code and
natively compiled code.

> otp_src_R12B-5/bin/erlc testmath.erl
> otp_src_R12B-5/bin/erl -noshell -run testmath main
0.0
> otp_src_R12B-5/bin/erlc +native testmath.erl
> otp_src_R12B-5/bin/erl -noshell -run testmath main
3.122502256758253e-17

> uname -a
Linux host 2.6.16.53-0.16-smp #1 SMP Tue Oct 2 16:57:49 UTC 2007 i686 i686
i386 GNU/Linux
---

-module(testmath).
-export([main/0]).

main()->
    foo(2/1600).

foo(Y)->
    io:format("~p~n",[Y*1200-1.5]),
    halt(0).

Best Regards /Fredrik Svahn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20081202/b68f8645/attachment.htm>


More information about the erlang-bugs mailing list