Octavian Rasnita <orasn...@gmail.com> asked:
> I have tried the following calculation with ActivePerl 5.10.0 build 1004
> under Windows XP Pro:
> 
> print 0.79 - 0.798;
> 
> And it gave the following result:
> -0.00800000000000001
> 
> which is obviously wrong.

No, it isn't. Welcome to the wonderful world of machine numbers.

Please read "perldoc -q number".

> It doesn't matter too much the reasons, but is there a better way for
> doing such math calculations in perl?

If you're dealing with money, it's a common practice to work with cents and 
integers instead of using floating point numbers.

HTH,
Thomas 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to