Math.ceil()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Math.ceil()
정적 메서드는 언제나 올림하여 주어진 숫자보다 크거나 같은 가장 작은 정수를 반환합니다.
시도해보기
console.log(Math.ceil(0.95));
// Expected output: 1
console.log(Math.ceil(4));
// Expected output: 4
console.log(Math.ceil(7.004));
// Expected output: 8
console.log(Math.ceil(-7.004));
// Expected output: -7
구문
js
Math.ceil(x)
매개변수
x
-
숫자
반환 값
x
보다 크거나 같은 가장 작은 정수를 반환합니다. -Math.floor(-x)
와 동일한 값입니다.
설명
ceil()
은 Math
의 정적 메소드이므로, 생성한 Math
객체(Math
는 생성자가 아닙니다)의 메서드로 사용하지 않고, 언제나 Math.ceil()
으로 사용하세요.
예제
Math.ceil() 사용하기
js
Math.ceil(-Infinity); // -Infinity
Math.ceil(-7.004); // -7
Math.ceil(-4); // -4
Math.ceil(-0.95); // -0
Math.ceil(-0); // -0
Math.ceil(0); // 0
Math.ceil(0.95); // 1
Math.ceil(4); // 4
Math.ceil(7.004); // 8
Math.ceil(Infinity); // Infinity
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.ceil |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ceil |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.