# Math.floor with negative numbers

Jasper Vader

Ranch Hand

Posts: 284

posted 13 years ago

hi there....

System.out.println(Math.floor(-2.1));

what do you think the answer is?

-3.0 that's what.

i thought it rounded towards zero...i guess it does with positive numbers, but the point is that .floor gets the lowest whole number... so therefore it must be -3.0 ... silly little things like that must be watched for on the exam eh.

System.out.println(Math.floor(-2.1));

what do you think the answer is?

-3.0 that's what.

i thought it rounded towards zero...i guess it does with positive numbers, but the point is that .floor gets the lowest whole number... so therefore it must be -3.0 ... silly little things like that must be watched for on the exam eh.

giddee up

John Lee

Ranch Hand

Posts: 2545