August 1999
Intermediate to advanced
1488 pages
72h 53m
English
math.round(num)
The round() method of the Math object is used to round a number to its nearest integer value. If the fractional portion of the number is .5 or greater, the result is rounded to the next highest integer. If the fractional portion of number is less than .5, the result is rounded to the next lowest integer.
Listing 6.171 shows how the round() method is used.
<html> <body> <script language="JavaScript"> <!–– Hide // function rounds input number to nearest integer function doMath(){ var inputNum1=document.form1.input1.value; var result = Math.round(inputNum1); document.form1.answer.value ... |
Read now
Unlock full access