[Python] Simulating integer overflow in Python

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    Python 2 has two integer datatypes int and long, and automatically converts between them as necessary, especially in order to avoid integer overflow.

    I am simulating a C function in Python and am wondering if there are standard ways to re-enable integer overflow. For the nonce, I've used

    overflow_point = maxint + 1
    if value > overflow_point:
    value -= 2 * overflow_point


    Is there a more standard way to do the same thing?

    Continue reading...

Compartilhe esta Página