I supposed you could get the int() method to work on negatives by using abs() and some arithmetic with it.
if ( $value < 0 ) { $rounded = ( int( abs($value) + 0.5) ); $rounded = $rounded - ( $rounded * 2 ); } else { $rounded = int($value + 0.5) }
or something...
Seems more complicated than sprintf() =)
--
Allolex
Update: Added closing bracket. (2003-05-15 19:27:26 CEST)
In reply to Re: •Re: Re: rounding to nearest integer
by allolex
in thread rounding to nearest integer
by dsm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |