[Python] Increment a Python floating point value by the smallest possible amount

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    How can I increment a floating point value in python by the smallest possible amount?


    Background: I'm using floating point values as dictionary keys.

    Occasionally, very occasionally (and perhaps never, but not certainly never), there will be collisions. I would like to resolve these by incrementing the floating point value by as small an amount as possible. How can I do this?

    In C, I would twiddle the bits of the mantissa to achieve this, but I assume that isn't possible in Python.

    Continue reading...

Compartilhe esta Página