Hacker News new | past | comments | ask | show | jobs | submit login

It rounds down the quotient



How intuitive. But thanks anyway.


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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: