+ 1

Why math.floor answers different for positive and negative numbers ?

I'm confused after getting the results..!🤔 1.math.floor(48.37) = 48 2.math.floor(-48.37) = -49

29th Aug 2020, 2:54 PM
Hari Gopal
Hari Gopal - avatar
9 odpowiedzi
+ 8
Math.floor rounds the number lower. Smaller than 48.37 is 48, smaller than -48.37 is -49
29th Aug 2020, 2:56 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 5
It kind of makes sense if you look at the numbers all in a row, starting at 0 with positives going up from, and negatives going downfrom 0. math.floor rounds down. 48 is less than 48.37 and -49 is (i guess) even more less than -48.37
29th Aug 2020, 2:58 PM
Slick
Slick - avatar
+ 2
Slick Thank you
29th Aug 2020, 2:59 PM
Hari Gopal
Hari Gopal - avatar
+ 2
It rounds always below number, it doesnt matter that is negative or positive
29th Aug 2020, 5:14 PM
Ramazan Semai AKSU
Ramazan Semai AKSU - avatar
+ 2
29th Aug 2020, 5:15 PM
Hari Gopal
Hari Gopal - avatar
+ 2
You welcome
29th Aug 2020, 5:16 PM
Ramazan Semai AKSU
Ramazan Semai AKSU - avatar
29th Aug 2020, 2:58 PM
Hari Gopal
Hari Gopal - avatar
+ 1
💜 Alex Tușinean 🍇 Slick What if math.round(-48.37) ? 1.48 2.49
29th Aug 2020, 3:03 PM
Hari Gopal
Hari Gopal - avatar
+ 1
print ( -15//2 ) = -8 Which among these functions are worked in expression , math.floor or math.round or else both
30th Aug 2020, 4:40 AM
Hari Gopal
Hari Gopal - avatar