0
Why In Floor Division the output comes 2 but when operating with floats it is 2.0 Why?
5 Respuestas
+ 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 ^^
+ 2
Really owe you vish
+ 2
Thanks Simba😎💞
+ 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
0
4 // 2 => 2
4 / 2 => 2.0
5 // 2 => 2
5 / 2 => 2.5