▶Math.ceil() : 올림 (실수형 유지)

Math.floor() : 내림 (실수형 유지)

Math.rint() : 반올림 (실수형 유지)

Math.round() : 반올림 (int형으로 반환)

System.out.println(Math.ceil(3.14));
System.out.println(Math.floor(3.14));
System.out.println(Math.rint(3.14));
System.out.println(Math.rint(3.51));
System.out.println(Math.round(3.51));
4.0
3.0
3.0
4.0
4

 

반응형

+ Recent posts