+ 1

What's the difference between floor division (//) and division (/)?

3rd Feb 2017, 7:11 PM
Arundhati
Arundhati - avatar
3 ответов
+ 13
/ type: standart division Returns: float exaple: 5 / 2 = 2.5 // type: floor division Returns: int if left and right side are integers, otherwise - float example: 5 // 2 = 2
3rd Feb 2017, 7:17 PM
WittyBit
WittyBit - avatar
+ 2
Considering '5' & '2' like an integer, the division's result will be an (integer). Example: 5 / 2 = 2 (int) 5 / 2. = 2.5 (float) 5 // 2 = 2 (int) 5 // 2. = 2.0 (float)
3rd Feb 2017, 7:33 PM
Adel
Adel - avatar
+ 1
Let me simplify what they are saying, floor division takes the remainder of a number and turns it into a float, for example 20/6 = 3.3333333333333335 while floor division "simplifies it" 20//6 = 3
6th Feb 2017, 10:36 PM
Gavin2722
Gavin2722 - avatar