Could someone verify I haven't lost my mind and run this code:

use strict;
use warnings;
my $x = .0006;
my $y = $x * 10000;
print $y , "\n";
print sprintf("%04d\n",$y);
print int($y), "\n";
__END__
I'm getting the unexpected results:
6
0005
5

why does .0006 * 10000 = 6 but "round" to 5?  Is this a precision issue I'm
not aware of? If it is it seems awfully shallow to lose information.

Comments appreciated!

-Wayne


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to