in reply to Methods to format a number
in thread Numbers....
You can get around the truncation problem fairly easily with:
Update: Well Alright then for the pedantic among us, see below ;-) (no offence meant, please don't take any)$string = int( ($number * 100) + 5 ) / 100;
That should sort out the rounding towards an even number.my $dec = 100; # Change as appropriate to give you the number # of decimal places you want int( ($number * $dec) + int($number * $dec) % 2 ? 0.5 * $dec : 0) / $dec
Nuance
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Methods to format a number
by Corion (Patriarch) on Jun 02, 2000 at 19:20 UTC | |
by Adam (Vicar) on Jun 02, 2000 at 21:07 UTC |