Weird 'and' result...
Mike C. Fletcher
mcfletch at rogers.com
Fri Jun 20 19:34:41 EDT 2003
More information about the Python-list mailing list
Fri Jun 20 19:34:41 EDT 2003
- Previous message (by thread): Weird 'and' result...
- Next message (by thread): Weird 'and' result...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Artur M. Piwko wrote: >pipen at demon:/tmp/ekg-1.1rc1$ python >Python 2.2.3 (#1, Jun 4 2003, 02:54:59) >[GCC 3.3 (Debian)] on linux2 >Type "help", "copyright", "credits" or "license" for more information. > > >>>>"%08x" % (0xea7ee5ccea7 & 0xffffffff) >>>> >>>> >'ea7ee5ccea7' > > > >And it should be 'ee5ccea7'. Am I missing something? > > Coercian to long to & with the left operand occurs *after* 0xffffffff is interpreted as regular integer -1. So, you're asking for: 0xea7ee5ccea7 & -1L And the -1 is intepreted as an "infinite stream of 1 bits" (or whatever Tim thinks of it as), so you get all the bits in your (long) left operand returned. You probably want this: >>> "%08x" % (0xea7ee5ccea7L & 0xffffffffL) 'ee5ccea7' That is, explicitly make both numbers long integers. HTH, Mike _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/
- Previous message (by thread): Weird 'and' result...
- Next message (by thread): Weird 'and' result...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list