>> Int returns the integer portion --> it truncates!
>Great, thanks for filling me in! So 6 truncates to 5 in perl?!? :-0

5.0 to 5.99999999999999999 truncates to 5.  Try this code:

use strict;
use warnings;
my $x = .0006;
my $y = $x * 10000;
print $y , "\n";
print sprintf("%04d\n",$y);
print sprintf("%04.20f\n",$y);
print int($y), "\n";
_END_
6
0005
5.99999999999999910000
5

You can see that $y isn't 6, but it's really close.  Print $y rounds,
sprintf(%d) truncates, and int() truncates.

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to