Python's // vs. C++/Java's /: Division Differences

Unlike C++ or Java, where integer division with `/` truncates towards zero, Python 3's `//` operator performs 'floor division,' rounding results towards negative infinity, especially evident with negative numbers (e.g., -5 // 2 yields -3, not -2).

Sources

Open the full topic