0

Hi all,
I need to set some variables via Pysnmp which take 'unsigned int' only.
Is python int by default a 32 bit- signed int? How do I convert it into 16 and 8 bit- unsigned ints? I need to read two registers consequently( which are of 8 bits each) and both of them together give me the desired result.

Can i just convert the result of snmp 'get' into a string, concatenate two strings and later convert it back to int using int()?

any help pls...

Edited by novice20: n/a

4
Contributors
4
Replies
9
Views
5 Years
Discussion Span
Last Post by vegaseat
Featured Replies
  • 1

    [QUOTE]Is python int by default a 32 bit- signed int?[/QUOTE]Python uses the system's, so 32 bit on a 32bit system and 64 bit on a 64 bit system. Note that there is no difference in length between a signed integer and an unsigned integer. A signed integer just uses one … Read More

1

Is python int by default a 32 bit- signed int?

Python uses the system's, so 32 bit on a 32bit system and 64 bit on a 64 bit system. Note that there is no difference in length between a signed integer and an unsigned integer. A signed integer just uses one of the bits as a sign, so an 8 bit unsigned can store 0-->255, and an 8 bit signed -127-->127 because one bit is used as a sign.

There is bitstring, bitbuffer and bitarray, Also, check PyPi for existing packages whenever you run into a problem like this .

Edited by woooee: n/a

0

In Python integers have a size only limited by your computer's memory. If you want to force compatibility with C you can use Python module struct

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.