英[ra?nd]? ?美[ra?nd]??
adj.圓形的;弧形的;豐滿的,肥胖的;整數(shù)的
adv.到處;在周圍;迂迴地;朝反方向
prep.大約;繞過,環(huán)繞;(表示位置)在…四周;附近
n.圓,圓形;循環(huán);圓形物,球狀物; (會(huì)議的)一回合
vt.& vi.使成圓形;繞行;拐過,繞過;把…四捨五入
第三人稱單數(shù): rounds 複數(shù): rounds 現(xiàn)在分詞: rounding 過去式: rounded 過去分詞: rounded 比較級(jí): rounder 最高級(jí): roundest
javascript round() 方法 語法
作用:把一個(gè)數(shù)字舍入為最接近的整數(shù)。
語法:Math.round(x)
#參數(shù):x ? ?必要。必須是數(shù)字。? ??
返回:與 x 最接近的整數(shù)。
說明:對(duì)於 0.5,此方法將進(jìn)行上舍入。例如,3.5 將舍入為 4,而 -3.5 將舍入為 -3。
javascript round() 方法 範(fàn)例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script type="text/javascript"> //不同的數(shù)舍入為最接近的整數(shù) document.write(Math.round(0.60) + "<br />") document.write(Math.round(0.50) + "<br />") document.write(Math.round(0.49) + "<br />") document.write(Math.round(-4.40) + "<br />") document.write(Math.round(-4.60)) </script> </body> </html>
執(zhí)行實(shí)例 ?
點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例