Bug in Python large negative literal assignment?
Alex Martelli
aleaxit at yahoo.com
Mon May 14 04:54:19 EDT 2001
"Keith Dart" <kdart at kdart.com> wrote in message
news:mailman.989824162.7613.python-list at python.org...
> On Mon, 14 May 2001, Roman Suzi wrote:
>
> > On Sun, 13 May 2001, Keith Dart wrote:
> >
> > That is because 2147483648 can not be represented by
> > 32 bits ;-)
>
> Thanks, but I know 2147483648 cannot be, but -2147483648 can be.
> I think Python aught to allow it.
In Python, sign characters are NOT part of numeric literals: they
are completely-separate operators, applied at runtime to whatever
number-object they affect, be it a literal one or not. This does
make things a little bit simpler and removes no capability.
> You're right, it is probably doing a
> negation on the positive literal, but I have to do some ugly
> work-arounds on my project because of this. But, I managed it by
> simply assigning it as a hexadecimal number.
See? No "ugly work-around" whatsoever. Just be sure to use
-sys.maxint-1 if THAT is what you mean (it will be different
on 64-bit machines), as indicated in the online docs for
module sys under entry maxint.
Alex
More information about the Python-list
mailing list