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 2005, 10:25:47)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> int('7d', 16)[/color][/color][/color]
125[color=blue][color=green][color=darkred]
>>> int('19', 16)[/color][/color][/color]
25[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
---------------------------
The problem is negative values. If the unit returns the hex value 'e7',
it means -25, but python says it's 231:
---------------------------[color=blue][color=green][color=darkred]
>>> int('e7', 16)[/color][/color][/color]
231
---------------------------
Does anyone have a clue a to what I need to do?
Thanks!
Andreas Lydersen
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 2005, 10:25:47)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> int('7d', 16)[/color][/color][/color]
125[color=blue][color=green][color=darkred]
>>> int('19', 16)[/color][/color][/color]
25[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
---------------------------
The problem is negative values. If the unit returns the hex value 'e7',
it means -25, but python says it's 231:
---------------------------[color=blue][color=green][color=darkred]
>>> int('e7', 16)[/color][/color][/color]
231
---------------------------
Does anyone have a clue a to what I need to do?
Thanks!
Andreas Lydersen
Comment