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...

Recommended Answers

All 4 Replies

pls... I am seeking out some help......

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 .

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.