[erlang-bugs] imprecise computation result

Eric Pailleau eric.pailleau@REDACTED
Thu Jun 6 10:44:54 CEST 2013


hello,
> 28.0e-1 * 2800.
7839.999999999999
but
> 28 * 2800  / 10.
7840.0

always tranlate reals into integers and then finally apply division of powers of ten.
reals are coded on a fix length of bits while decimals of the reals can be infinite.
it is due to computer architectures and all languages, even C, are impacted.
regards

« Envoyé depuis mon mobile » Eric

Xu Yifeng <zfsgeek@REDACTED> a écrit :

>Erlang's matchematic is crazy:
>
>Erlang R15B03 (erts-5.9.3.1) [source] [smp:2:2] [async-threads:0] [hipe] 
>[kernel-poll:false]
>
>Eshell V5.9.3.1  (abort with ^G)
>1> 2.8 * 2800.
>7839.999999999999
>2>
>
>
>but the result should be 7840.
>
>--
>Xu Yifeng
>
>
>_______________________________________________
>erlang-bugs mailing list
>erlang-bugs@REDACTED
>http://erlang.org/mailman/listinfo/erlang-bugs


More information about the erlang-bugs mailing list