java/코드 리뷰

12. lang2 - (1) MathDemo (Math 메서드 사용)

Astaroth아스 2020. 4. 23. 19:38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package lang2;
 
import static java.lang.Math.ceil;
import static java.lang.Math.floor;
import static java.lang.Math.rint;
import static java.lang.Math.round;
 
public class MathMDemo {
    public static void main(String[] args) {
        
        System.out.println(round(-1.2+ "," + round(-1.9+ "," + round(1.2+ "," + round(1.9));
        System.out.println(rint(-1.2+ "," + rint(-1.9+ "," + rint(1.2+ "," + rint(1.9));
        System.out.println(floor(-1.2+ "," + floor(-1.9+ "," + floor(1.2+ "," + floor(1.9));
        System.out.println(ceil(-1.2+ "," + ceil(-1.9+ "," + ceil(1.2+ "," + ceil(1.9));
        
        /*
        -1,-2,1,2
        -1.0,-2.0,1.0,2.0
        -2.0,-2.0,1.0,1.0
        -1.0,-1.0,2.0,2.0
         */
    }
}