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

Bob Ippolito bob@REDACTED
Wed Nov 27 03:42:40 CET 2013


PHP's echo is rounding the result, losing some precision in the process.
Erlang, Python, Ruby, Haskell, JavaScript, etc. print floating point
numbers in the shell without loss of precision.




On Tue, Nov 26, 2013 at 6:01 PM, Sanath Prasanna <ahe.sanath@REDACTED>wrote:

> 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
>>
>>
>>
>>
>
> _______________________________________________
> 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/20131126/ae083eb5/attachment.htm>


More information about the erlang-questions mailing list