the_slycer has asked for the wisdom of the Perl Monks concerning the following question:
I'd expect results like:my (@numbers) = qw( 0.256 0.255 0.254 ); printf("%0.2f\n", $_) foreach @numbers; printf("%0.2f\n", 1.255);
But what I'm seeing are results like:0.26 0.26 0.25 1.26
Notice the 1.25 vs 1.26 that I'd expect..0.26 0.26 0.25 1.25
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rounding a number using (s)printf
by dave_the_m (Monsignor) on Jan 19, 2005 at 22:26 UTC | |
|
Re: Rounding a number using (s)printf
by borisz (Canon) on Jan 19, 2005 at 22:36 UTC | |
|
Re: Rounding a number using (s)printf
by data64 (Chaplain) on Jan 20, 2005 at 03:56 UTC | |
|
Re: Rounding a number using (s)printf
by hsinclai (Deacon) on Jan 19, 2005 at 22:31 UTC | |
|
Re: Rounding a number using (s)printf
by duff (Parson) on Jan 20, 2005 at 00:38 UTC | |
by Anonymous Monk on Jan 20, 2005 at 09:55 UTC | |
by ysth (Canon) on Jan 20, 2005 at 22:45 UTC | |
|
Re: Rounding a number using (s)printf
by nite_man (Deacon) on Jan 20, 2005 at 08:50 UTC | |
by Anonymous Monk on Jan 20, 2005 at 10:02 UTC |