+ 2

# Floor Division on Floating Numbers--

Why is it that Floor Division on a Floating Number, e.g "12.0//6" does not return an integer, being "2", but instead returns another Floating Number, being "2.0"?

2 Answers

+ 2

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.

0

"12.0//6" is showing "2.0" because "12.0" is a floating number and "6" is int, but as the rule suggests the interpreter implicitly converts the result into floating point number. The operation gives the integer result but due the nature of one of the input it is converted into floating point after the operations is performed.