This page was translated from English by the community.Learn more and join the MDN Web Docs community.
Math.round()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
Math.round() 함수는 입력값을 반올림한 수와 가장 가까운 정수 값을 반환합니다.
In this article
시도해 보기
console.log(Math.round(0.9));// Expected output: 1console.log(Math.round(5.95), Math.round(5.5), Math.round(5.05));// Expected output: 6 6 5console.log(Math.round(-5.05), Math.round(-5.5), Math.round(-5.95));// Expected output: -5 -5 -6문법
Math.round(x);매개 변수
x수
반환 값
입력값을 반올림한 값과 가장 가까운 정수를 의미합니다.
Description
If the fractional portion of the argument is greater than 0.5, the argument is rounded to the integer with the next higher absolute value. If it is less than 0.5, the argument is rounded to the integer with the lower absolute value. If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞.Note that this differs from many languages'round() functions, which often round this case to the next integeraway from zero, instead giving a different result in the case of negative numbers with a fractional part of exactly 0.5.
Becauseround() is a static method ofMath, you always use it asMath.round(), rather than as a method of aMath object you created (Math has no constructor).
Examples
Math.round(20.49); // 20Math.round(20.5); // 21Math.round(42); // 42Math.round(-20.5); // -20Math.round(-20.51); // -21명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-math.round> |