[erlang-questions] Maths Problem -> 2452.45*100. = 245244.99999999997

Sanath Prasanna ahe.sanath@REDACTED
Wed Nov 27 03:01:12 CET 2013


I accepted your comment. But generally we expected full value. I did same
in another scripting language like php. It is given correct result. Thats
why I asked this question.
<?php
$a=2452.45*100;
echo $a;
exit;
?>
245245






On Wed, Nov 27, 2013 at 7:05 AM, Dave Cottlehuber <dch@REDACTED> wrote:

> 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
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131127/f886e327/attachment.htm>


More information about the erlang-questions mailing list