A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-October/029707.html below:

[Python-Dev] Memory size overflows

[Python-Dev] Memory size overflowsGerald S. Williams gsw@agere.com
Mon, 21 Oct 2002 09:33:52 -0400
Tim Peters wrote:
> Goodness no -- that kind of cleverness is usually buggy, and usually by
> failing to account for that the moral equivalent of -sys.maxint-1 is a fine
> product, but sys.maxint+1 isn't.

Agreed. Also, signed values needn't be 2's complement numbers,
and the behavior of signed overflow isn't guaranteed (it could
saturate, for instance). The use of doubles makes sense from a
portability standpoint. Or you could break out the signs and
use unsigned longs with preprocessor (and configure) checks,
being careful about performance impact. :-)

For example, you might need to do something equivalent to this:

#if HAVE_LIMITS_H
#define MAX_POSITIVE_LONG_VALUE (LONG_MAX)
#if -(LONG_MAX) == LONG_MIN
#define MAX_NEGATIVE_LONG_VALUE (LONG_MAX)
#elif (-(LONG_MAX) - 1) == LONG_MIN
#define MAX_NEGATIVE_LONG_VALUE ((LONG_MAX) + 1)
#else
#undef MAX_POSITIVE_LONG_VALUE
...

-Jerry



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4