[Python-Dev] Sign of bytes

anatoly techtonik techtonik at gmail.com
Wed Oct 31 18:54:46 CET 2012


The thing that made me wonder is here - http://bugs.python.org/issue16376
When I inspect contents of Windows structures, I get negative values that
are not present in MSDN.

-- 
anatoly t.


On Wed, Oct 31, 2012 at 7:44 PM, anatoly techtonik <techtonik at gmail.com>wrote:

> Hi,
>
> I wonder why Python uses signed chars for bytes
> http://docs.python.org/2/library/ctypes.html#ctypes.c_byte
>
> This is a Java thing, but Java doesn't have unsigned types at all
> http://en.wikipedia.org/wiki/Criticism_of_Java#Unsigned_integer_types
>
> Windows implements BYTE as unsigned char, and it is in the same line as
> WORD, DWORD etc. The way you look at memory contents in assembly.
>
> byte type is also unsigned in .NET platform for all languages implementes,
> and also has a sbyte counterpart.
>
> When working with bytes in decimal system it is much more convenient to
> operate with strictly positive values than with -128 - 127 (or is it -127
> to 128?)
>
>
> --
> anatoly t.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121031/2f36a1b5/attachment.html>


More information about the Python-Dev mailing list