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/2006-February/060335.html below:

[Python-Dev] Octal literals

[Python-Dev] Octal literals [Python-Dev] Octal literalsJames Y Knight foom at fuhm.net
Thu Feb 2 21:26:24 CET 2006
On Feb 2, 2006, at 7:11 PM, Bengt Richter wrote:
> [1] To reduce all this eye-glazing discussion to a simple example,  
> how do people now
> use hex notation to define an integer bit-mask constant with bits  
> 31 and 2 set?

That's easy:
0x80000004

That was broken in python < 2.4, though, so there you need to do:
MASK = 2**32 - 1
0x80000004 & MASK
> (assume 32-bit int for target platform, counting bit 0 as LSB and  
> bit 31 as sign).

The 31st bit _isn't_ the sign bit in python and the bit-ness of the  
target platform doesn't matter. Python's integers are arbitrarily  
long. I'm not sure why you're trying to pretend as if python was C.

James
More information about the Python-Dev mailing list

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