[erlang-bugs] Sum small floats and get erroneous result in R12B-2

Badlop <>
Wed May 28 13:27:50 CEST 2008


Hi,

It seems I found a bug in Erlang/OTP R12B-2 [1].
It only happens with certain operations and certain operands.
I haven't investigated what is the cause,
so I can only provide an example:

$ erl
Erlang (BEAM) emulator version 5.6.2 [source] [smp:2]
[async-threads:0] [kernel-poll:false]

Eshell V5.6.2  (abort with ^G)
1> 20.14 + 2.01.
22.15
2> 20.15 + 2.01.
22.159999999999997
3> 20.16 + 2.01.
22.17
4> 21.15 + 1.01.
22.16
5> 120.15 + 2.01.
122.16000000000001
6> 1120.15 + 2.01.
1122.16


We see that 1, 3, 4 and 6 provide the exact result.
But the results of 2 and 5 look strange.


Using OTP R11B-5 all works correctly:

$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0]
[kernel-poll:false]

Eshell V5.5.5  (abort with ^G)
1> 20.15 + 2.01.
22.1600


[1] It was reproducible with Debian package 1:12.b.2-dfsg-3 linux-x86
and macosx-intel.



More information about the erlang-bugs mailing list