Help: C char bits operations to python converting

Tim Peters tim_one at email.msn.com
Wed Sep 27 16:20:30 EDT 2000


[Joshua]
> def SignExtend(char):
>     if char & 0x80:
>         char = char ^ 0xffffff00
>     return char
>
> yes?

[/F]
> no.  don't assume that all platforms use 32-bit integers.

def SignExtend(char):
    return char | -(char & 0x80)






More information about the Python-list mailing list