Movatterモバイル変換


[0]ホーム

URL:


  1. 개발자를 위한 웹 기술
  2. JavaScript
  3. JavaScript 참고서
  4. 표준 내장 객체
  5. Math
  6. Math.round()

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

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() 함수는 입력값을 반올림한 수와 가장 가까운 정수 값을 반환합니다.

시도해 보기

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

문법

js
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

js
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

브라우저 호환성

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp