[TIL] Math.ceil / Math.floor / Math.round

Mintaek·2023년 1월 10일
post-thumbnail

Math.ceil

Math.ceil 은 소수값이 존재할 때 값을 올리는 역활을 하는 함수

예제

Math.ceil(.95);
//expected output : 1

Math.ceil(-0.95)
//expected output : -0

Math.floor

Math.floor 은 소수값이 존재할 때 소수값을 버리는 역활을 하는 함수

예제

Math.floor(123.5);
//expected output : 123

Math.floor(-123.5)
//expected output : -124

Math.round

Math.round 는 소수값에 따라 올리거나 버리는 역활을 하는 반올림 함수

예제

Math.round(123.5);
//expected output : 124

Math.round(-123.5)
//expected output : -122
profile
Slow and Steady Wins the Race

0개의 댓글