What is the difference between division (/) and floor division (//) ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between division (/) and floor division (//) ?

8th Jan 2017, 5:03 AM
Paramasivam
Paramasivam - avatar
9 Answers
+ 10
5/2 = 2.5 5//2 = 2
8th Jan 2017, 5:04 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
Mohamed is right. Even if result is 2.99, output will be considered as 2 only
8th Jan 2017, 9:22 PM
Krishna
+ 2
i dont know if i say the right answer but i think floor division just keep the number without any decimal
8th Jan 2017, 7:47 AM
mohammad
mohammad - avatar
+ 2
what everyone said is wrong .. / division gives the answer to a division between two numbers so 20/8=2.5 for example a//b tells you how many times you can devide a by b. 20//8 how many time can you divide 20 by 8? 2 times 2×8=16.. that's the difference
9th Jan 2017, 2:32 AM
ramzi
ramzi - avatar
+ 1
Floor division rounds the result down to a full number, so yes, 2.5 becomes 2
8th Jan 2017, 1:40 PM
Andrew Prohhorov
Andrew Prohhorov - avatar
+ 1
yes. its right. but the result is same. i said your answer with different language. the result is important. both two answers are equal
9th Jan 2017, 3:39 AM
mohammad
mohammad - avatar
0
So... if i get it right, (11//2=5) because i can divide 5 times 11 by 2 but ... now where'is the rest?
10th Jan 2017, 1:18 PM
Adrian Nazaruk
Adrian Nazaruk - avatar
0
Adrian, there is no more. In that operation the remainder is discarded. So 20//8 is 2 and the remainder of .5 would be dropped in this operation. It only uses the number of times yoo can divide by a whole number evenly
13th Jan 2017, 2:30 PM
Kevin
0
to get the rest there is another symbol, the percentage % to get the remainder of a number divided by another
13th Jan 2017, 4:04 PM
ramzi
ramzi - avatar