I know how the // operator works, but what is going on behind the scenes?
What I really want to know: Is it subject to floating point precision errors even when operating exclusively on integers?
Python does not use floating point arithmetic when calculating a // b
(for a, b integers). An implementation of the classical long division algorithm to calculate the quotient and remainder when dividing a
and b
.
The actual division for large integers is implemented in x_divrem()
which is found in longobject.c.