daptal has asked for the wisdom of the Perl Monks concerning the following question:
perl -e 'use strict; use warnings; my @num = (3.95,4.95,5.95,8.95,8.94 +,8.96,9.95,9.96,9.97,9.94,10.08); foreach (@num){ my $num = $_ *100; print "$num\t"; my $tmp = sprintf("%010d", $num); print "$tmp\n"; }' 395 0000000395 495 0000000495 595 0000000595 895 0000000894 894 0000000894 896 0000000896 995 0000000994 996 0000000996 997 0000000997 994 0000000994 1008 0000001008
I was testing and found this. Why does this happen ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sprintf values
by Ratazong (Monsignor) on Apr 07, 2010 at 06:59 UTC | |
|
Re: sprintf values
by Anonymous Monk on Apr 07, 2010 at 07:00 UTC | |
|
Re: sprintf values
by cdarke (Prior) on Apr 07, 2010 at 08:26 UTC | |
by almut (Canon) on Apr 07, 2010 at 15:41 UTC | |
by ikegami (Patriarch) on Apr 07, 2010 at 16:18 UTC | |
by almut (Canon) on Apr 07, 2010 at 17:09 UTC | |
by ikegami (Patriarch) on Apr 07, 2010 at 18:39 UTC | |
|
Re: sprintf values
by ikegami (Patriarch) on Apr 07, 2010 at 14:52 UTC | |
|
Re: sprintf values
by stefbv (Priest) on Apr 07, 2010 at 08:24 UTC |