본문 바로가기
Coding With Jina/JavaScript

[자바스크립트] 소수점 올림/버림/반올림-ceil( )/floor( )/round( )

by 진아리♡ 2021. 8. 26.
728x90
반응형

▶ 소수점 올림 Math.ceil( )

Math.ceil(변환하고자 하는 소수값);


//예시
console.log(Math.ceil(15.45));

//결과  =>  16

 

 

▶ 소수점 버림 Math.floor( )

Math.floor(변환하고자 하는 소수값);


//예시
console.log(Math.floor(15.45));

//결과  =>  15

 

 

▶ 소수점 반올림 Math.round( )

Math.round(변환하고자 하는 소수값);


//예시1
console.log(Math.round(15.45));

//결과  =>  15


//예시2
console.log(Math.round(15.7));

//결과  =>  16
728x90
반응형