Math.round() FunctionNameMath.round() Function---round to the nearest integerAvailabilityNavigator 2.0, Internet Explorer 3.0 Synopsis
Math.round(x) Arguments
ReturnsThe integer closest to x. DescriptionMath.round() rounds its argument up or down to the nearest integer. BugsIn Navigator 2.0, Math.round() did not correctly round very large numbers. The following workaround can be used:
function my_round(num) { var fl = Math.floor(num); var ce = Math.ceil(num); return (fl == ce) ? num : ((num - fl) < (num - ce)) ? fl : ce; } |
|