본문 바로가기

Java

[java] Class Math : 올림, 내림, 반올림 등 Method

🍅 실제 사용 형식

className.methodName(variableName)


 

올림

Math.ceil(double a) : return double

 

내림

Math.floor(double a) : return double

 

반올림

Math.round(double a) : return long

Math.round(float a) : return int

 

Math.floorDiv(int x, int y) : return int

Math.floorDiv(long x, long y) : return long

 

나머지

Math.floorMod(int x, int y) : return int

Math.floorMod(long x, long y) : return long

 

절대값

Math.abs(double a) : return double

Math.abs(float a) : return float

Math.abs(int a) : return int

Math.abs(long a) : return long


 

🥕 출처

https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html