March 2002
Intermediate to advanced
528 pages
21h 29m
English
round
double round(doublenumber[, intprecision])
Returns the integer value nearest to
number at the
precision number of decimal places. The
default for precision is 0 (integer rounding).
Note that this function provides proper rounding—odd whole
numbers are rounded up on a .5, even whole numbers are rounded down
on a .5. That is:
$first = round(1.5); // $first is 2 $second = round(2.5); // $second is also 2!
If you want the rounding taught to you in grade school, either add a
small number (smaller than the precision you’re
after), or, if you’re using whole numbers, add .5
and call floor( ) on the result.