Re: Type Conversions for unsigned integers
Nikolaus Rath <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
"Mark Tolonen" <[email protected]> writes: > "Nikolaus Rath" <[email protected]> wrote in message > news:[email protected]... >> Hello, >> >> Why does the c_uint8 type behave so different from the others? >> >>>>> c_uint8(-1).value >> -1 >>>>> c_uint16(-1).value >> 65535 >>>>> c_uint32(-1).value >> 4294967295L >>>>> c_uint(-1).value >> 4294967295L > > Because you need to upgrade? > > Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] > on > win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from ctypes import * >>>> c_uint8(-1).value > 255 > > What version of Python are you using (and ctypes, if it wasn't bundled)? Ubuntu Karmic Python & bundled ctypes: $ python Python 2.6.4 (r264:75706, Nov 2 2009, 14:38:03) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> c_uint8(-1).value 255 Ok. Now I'm really confused. Yesterday it wasn't working, and I certainly haven't upgraded Python since then.. -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users