[Math] Math.ceil() / Math.floor() / Math.round() (올림 / 내림 / 반올림)

Sejung Seo·2022년 6월 12일
0

JavaScript

목록 보기
3/19
post-thumbnail

올림 : ceil = v. 천장에 대다

let positiveNum_ceil = Math.ceil(3.6)
    
//양수 3.6의 올림
    
console.log(’positiveNum_ceil’, positiveNum_ceil)
    
//4
    

let negativeNum_ceil = Math.ceil(-3.6)
    
//음수 -3.6의 올림
    
console.log(’negativeNum_ceil’, negativeNum_ceil)
    
//-3

내림 : floor = v. 바닦에 깔다

let positiveNum_floor = Math.floor(3.6)
    
//양수 3.6의 내림
    
console.log(’positiveNum_floor’, positiveNum_floor)
    
//3
    
let negativeNum_floor = Math.floor(-3.6)
    
//음수 -3.6의 내림
    
console.log(’negativeNum_floor’, negativeNum_floor)
    
//-4

반올림 : round = v. 반올림하다

let positiveNum_round = Math.round(3.6)
    
//양수 3.6의 반올림
    
console.log(’positiveNum_round’, positiveNum_round)
    
//4
    
let negativeNum_round = Math.round(-3.6)
    
//음수 -3.6의 반올림
    
console.log(’negativeNum_round’, negativeNum_round)
    
//-4
profile
공부하는 코린이 🌼

0개의 댓글