Es6-math-round

提供:Dev Guides
2020年6月23日 (火) 08:04時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

ES6-数学のround()関数

数値を最も近い整数に丸めます。

構文

Math.round( x ) ;

パラメータ

  • X-数値を表します

console.log("---Math.round()---")
console.log("Math.round(7.2) : "+Math.round(7.2))
console.log("Math.round(-7.7) : "+Math.round(-7.7))

出力

---Math.round()---
Math.round(7.2) : 7
Math.round(-7.7) : -8