Plz explain why a negative value inside a floor acts like ceiling and vice versa | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Plz explain why a negative value inside a floor acts like ceiling and vice versa

Example.. System.out.print(Math.floor(3.6)); -->3 System.out.print(Math.floor(-3.6)); -->-4 //why not -3?

28th Oct 2019, 4:02 AM
Sanzid Sadman
Sanzid Sadman - avatar
1 Answer
+ 10
Math.floor rounds the number you chose to the lower full number. It is 3 because 3 < 3.6 It is -4 because -4 < -3.6
28th Oct 2019, 4:21 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar