[Python-Dev] Unclear on the way forward with unsigned integers

Thomas Heller thomas.heller@ion-tof.com
Mon, 7 Oct 2002 22:03:56 +0200


> [Mark Hammond]
> > While this case seems quite trivial, I am starting to face this issue
> > more and more, especially as I am seeing these lovely "FutureWarnings"
> > from all my lovely 32 bit hexadecimal constants <wink/frown>
> 
> [Tim]
> > Sticking "L" at the end is usually all it takes.
> 
> [Thomas Heller]
> > That removes the warnings for 'x = 0x80000000L'.
> 
> What else do you think Mark may have meant by "32 bit hexadecimal
> constants"?
> 
> > Is there a way (other than the -w command-line arg)
> > to suppress the warnings when doing 'hex(-1)'?
> 
> The result of that is also currently platform-dependent, so you need to say
> what you mean in a platform-independent way.  It's likely that you meant
> 
>     hex(-1 & 0xffffffffL)
> 
> or, more directly,
> 
>     hex(0xffffffffL)
> 
> but that someone on a 64-bit box meant something other than that.
> 
> > Shouldn't there be a __future__ option?
> 
> You seem to want most of all to avoid warning msgs, but __future__ options
> don't accomplish that:  it's the *point* of __future__ thingies to spit out
> warnings about semantics that are going to change.
Yes, I want to avoid the warnings.

I've reread pep237 (is this the relevant one?) again.
Do I understand this correctly, that all the following expressions
will be 'true' and will compile/execute without any warnings (on
a 32bit box):

Python 2.2:
0x80000000 == -2147483648

Python 2.3:
0x80000000L == 2147483648

Python 2.x (Phase B1?):
0x80000000L == 2147483648

Python 2.y (Phase B2 and later):
0x80000000 == 2147483648

Regards,

Thomas