Re: Negative hex to int

2006-06-14 Thread Ben Finney
John Machin <[EMAIL PROTECTED]> writes: > On 15/06/2006 10:31 AM, Ben Finney wrote: > > If you want a special interpretation of the value, you'll have to > > calculate it. > > > > Example assuming you want a one's-complement interpretation:: > > Given that the OP had to ask the question at all,

Re: Negative hex to int

2006-06-14 Thread John Machin
On 15/06/2006 10:31 AM, Ben Finney wrote: > [EMAIL PROTECTED] writes: > >> The problem is negative values. If the unit returns the hex value >> 'e7', it means -25, but python says it's 231: > > Python is right. There is no "negative bit" in Python numbers, now > that unification of 'long' and 'in

Re: Negative hex to int

2006-06-14 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi! > > While communicating with a monitoring unit, I get some hex values > representing degrees celcius from its probes. The values can be > something like '19' or '7d'. To convert it to int, I do the following: > --- > Python 2.4.2 (#1, Sep 28 2

Re: Negative hex to int

2006-06-14 Thread Ben Finney
[EMAIL PROTECTED] writes: > The problem is negative values. If the unit returns the hex value > 'e7', it means -25, but python says it's 231: Python is right. There is no "negative bit" in Python numbers, now that unification of 'long' and 'int' is complete; numbers can grow indefinitely large.

Re: Negative hex to int

2006-06-14 Thread John Machin
On 15/06/2006 9:24 AM, Wojciech Muła wrote: > [EMAIL PROTECTED] wrote: >> The problem is negative values. If the unit returns the hex value 'e7', >> it means -25, but python says it's 231: >> --- > int('e7', 16) >> 231 >> --- >> >> Does anyone hav

Re: Negative hex to int

2006-06-14 Thread Wojciech Muła
[EMAIL PROTECTED] wrote: > The problem is negative values. If the unit returns the hex value 'e7', > it means -25, but python says it's 231: > --- int('e7', 16) > 231 > --- > > Does anyone have a clue a to what I need to do? def u2(x): i

Re: Negative hex to int

2006-06-14 Thread John Machin
On 15/06/2006 9:09 AM, [EMAIL PROTECTED] wrote: > Hi! > > While communicating with a monitoring unit, I get some hex values > representing degrees celcius from its probes. The values can be > something like '19' or '7d'. To convert it to int, I do the following: > --- > Pyt