[erlang-questions] In Erlang , {1.1*1.1.} show me the answer is 1.2100000000000002, why?

Eric Pailleau eric.pailleau@REDACTED
Sun Oct 26 10:04:13 CET 2014


Hi,
you will have this problem with any programming language, it is due to float representation in computers.
the lonely way is to work with integers and divide by power of 10.
11*11/100   .



« Envoyé depuis mon mobile » Eric

张栋 <zd2559@REDACTED> a écrit :

>Hello the maillist member:
>I am  new in Erlang,Please Help me.
>
>When I try some multiplication, I got the some unexpected answer about the following expression.
>
>Please help!
>
>List:
>
>23> [1.1*1.1,1.1*1.2,1.1*1.3,1.1*1.4,1.1*1.5].
>[1.2100000000000002,1.32,1.4300000000000002,1.54,
> 1.6500000000000001]
>
>24> [1.2*1.2,1.2*1.3,1.2*1.4,1.2*1.5,1.2*1.6].
>[1.44,1.56,1.68,1.7999999999999998,1.92]
>
>Thank you for your time.
>
>Eric D. Zhang In China.
>
>
>_______________________________________________
>erlang-questions mailing list
>erlang-questions@REDACTED
>http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141026/5aac0028/attachment.htm>


More information about the erlang-questions mailing list