[erlang-questions] Maths Problem -> 2452.45*100. =?utf-8?Q?=3D_?=245244.99999999997

Dave Cottlehuber dch@REDACTED
Wed Nov 27 02:35:35 CET 2013


On 27. November 2013 at 02:33:05, Sanath Prasanna (ahe.sanath@REDACTED) wrote:
>  
> Hi all,
> when running following sample in ERL shell, I got wrong value.  
> What is the
> reason for this?
>  
> 2452.45*100. = 245244.99999999997
>  
> It should be 245245.0 or 245245

Hi Sanath,

Unfortunately not, welcome to Computing :-), the shell is right.

> Then all the calculations became wrong in my program.
> Are there any idea regarding above?
>  
> Br,
> Sanath

The best explanation I’ve found is here:

    http://floating-point-gui.de/

For an in-depth explanation, read 

    http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

A+
Dave






More information about the erlang-questions mailing list