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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)