On 2012-04-27, Grant Edwards wrote:
> On 2012-04-27, Grant Edwards wrote:
>> On 2012-04-27, Paul Rubin wrote:
>>> python writes:
What to decode hex '0xC0A8' and return signed short int.
>>>
>>> Is this right?
>>>
>>> n = int('0xC0A8', 16)
>>> if n >= 0x:
>>>n -= 0x1000
On 2012-04-27, Grant Edwards wrote:
> On 2012-04-27, Paul Rubin wrote:
>> python writes:
>>> What to decode hex '0xC0A8' and return signed short int.
>>
>> Is this right?
>>
>> n = int('0xC0A8', 16)
>> if n >= 0x:
>>n -= 0x1
>
> Yes, as long as the input value doesn't ex
On 27/04/2012 20:32, Ian Kelly wrote:
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote:
python writes:
What to decode hex '0xC0A8' and return signed short int.
Is this right?
n = int('0xC0A8', 16)
if n>= 0x:
n -= 0x1
No.
n = int('0xC0A8', 16)
if n>= 0x800
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
> n -= 0x1
No.
n = int('0xC0A8', 16)
if n >= 0x8000:
n -= 0x1
--
http://mail.
Steven D'Aprano writes:
>> Is this right?
>>
>> n = int('0xC0A8', 16)
>> if n >= 0x:
>>n -= 0x1
> No.
Oops, I meant n >= 0x7fff. Checking the sign bit.
Grant Edwards writes:
> Yes, as long as the input value doesn't exceed 0x1. This is
> probably better:
>
> n
On 2012-04-27, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
>n -= 0x1
Yes, as long as the input value doesn't exceed 0x1. This is
probably better:
n = int(
On Fri, 27 Apr 2012 11:56:45 -0700, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
>n -= 0x1
No.
>>> struct.unpack('>h',b'\xC0\xA8')
(-16216,)
>>> n = int('0xC0
python writes:
> What to decode hex '0xC0A8' and return signed short int.
Is this right?
n = int('0xC0A8', 16)
if n >= 0x:
n -= 0x1
--
http://mail.python.org/mailman/listinfo/python-list