0

Why In Floor Division the output comes 2 but when operating with floats it is 2.0 Why?

3rd Jul 2021, 5:17 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
5 Antworten
+ 2
because "floor" division is "whole" (integer) division... so it return integer result... float division return 2.0 only if rest of whole division is 0 ^^
3rd Jul 2021, 5:19 AM
visph
visph - avatar
+ 2
Really owe you vish
3rd Jul 2021, 5:25 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
+ 2
Thanks Simba😎💞
3rd Jul 2021, 5:38 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
+ 1
I think you're talking about this case. 12//6 = 2 12.0//6 = 2.0 Because if either member is float, the return value is also float. In the case you want integer result, you can retype it with (int) value. int(12.0)//6 = 2
3rd Jul 2021, 5:36 AM
Simba
Simba - avatar
0
4 // 2 => 2 4 / 2 => 2.0 5 // 2 => 2 5 / 2 => 2.5
3rd Jul 2021, 5:22 AM
visph
visph - avatar