overflow exceptions

Doug Moen (dmoen@io.org)
Sat, 18 Dec 93 04:54 WET

Tim Peters:
> bumpedi = 0
> try:
> x = y*i
> not try:
> i = i + 1
> bumpedi = 1
> x = x*i
> except OverflowError:
> i = i - bumpedi
> x = long(y)*i
> i = i + 1
> x = x * i
>
> ... I do a lot of
> number-crunching in Python, and for speed I often do computations with
> short integers, knowing in advance that every now & again they'll
> overflow. In the rare case that they do overflow, I simply redo the
> computation using long arithmetic. Is this sick? Sure.

Of course, all of this trauma would be unnecessary if short integer
operations returned long integers if the result is too large to fit in
a short. Let's abolish overflow errors!