+ 3

how math.floor() works in java?

give few examples of math.floor() ... in java.

14th Jan 2019, 3:13 PM
suman Kayal
suman Kayal - avatar
2 odpowiedzi
+ 11
● How to use it ? (Sample code) : double x=1.5,y=-1.5; System.out.print(Math.floor(x)+" "+Math.floor(y)); //1.0 -2.0 ● How it works ? It works like Greatest Integer Function( gif), For example: ○ gif(N) = N //if N is an integer. ○ gif(N) = A //if N is an number between two closest integers A & B, we took the integer of lower value. ● it returns double value
14th Jan 2019, 5:05 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
floor(12.999) == 12 floor(345.34) == 345 It just rounds down.
14th Jan 2019, 4:01 PM
Maneren
Maneren - avatar