in reply to Rounding up nearest ten, hundred etc
could beelsif($length == 2) { $num = (substr($num, 0, 1) + 1) . ('0'x($length-1)); }
or evenelsif($length == 2) { $num = (substr($num, 0, 1) + 1) . '0'; }
since $length is known to be 2.elseif($length == 2){ $num = int($num/10) * 10; }
But I am confused. In your example numbers of 1, 2 and 3 digits round to the nearest 10 and numbers of 4 digits round to the nearest 100. Could you please be more explicit about when to round to what?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rounding up nearest ten, hundred etc
by nite_man (Deacon) on Sep 27, 2004 at 17:03 UTC | |
by Zed_Lopez (Chaplain) on Sep 27, 2004 at 21:48 UTC |