Hacker News new | ask | show | jobs
by the-dude 2394 days ago
How intuitive. But thanks anyway.
1 comments

In Python 2, floor division is the default for integer arguments and exact (to within machine precision) division the default for floating point arguments, but this caused a lot of unnecessary confusion: new users were surprised that 3.0/2.0 == 1.5, but 3/2 == 1.

Thus for Python 3 the new // operator was added for explicit floor division (which is often quite useful in its own right), leaving the / operator to always return an exact (to machine precision) floating point result, even with integer arguments.

cf. https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...