Java - How to do floor division?
You can do
double val = 5 / 2;
int answer = Math.floor(val);
OR
int answer = Math.floorDiv(5, 2);
If you were to call System.out.println(answer);
the output would be
2
You can easily use Math.floorDiv() method. For example:
int a = 15, b = 2;
System.out.println(Math.floorDiv(a, b));
// Expected output: 7