From: "Thomas Bätzler" <t.baetz...@bringe.com>
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.
Well, in PHP that calculation is made well, so I think there is a bug in
perl.
Anyway, I knew about this issues in languages like perl and python, but I
hoped there should be a solution for it and I found that I can use
Math::BigFloat:
use strict;
use Math::BigFloat;
my $x = 0.079;
my $y = 0.085;
#$x = Math::BigFloat->new($x);
#$y = Math::BigFloat->new($y);
print $x - $y;
Octavian
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/