+ 3
how math.floor() works in java?
give few examples of math.floor() ... in java.
2 Answers
+ 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
+ 3
floor(12.999) == 12
floor(345.34) == 345
It just rounds down.