How to convert signed to unsigned integer in Python ? Last Updated : 05 Apr, 2021 Comments Improve Suggest changes Like Article Like Report Python contains built-in numeric data types as int(integers), float, and complex. Compared to C programming, Python does not have signed and unsigned integers as data types. There is no need to specify the data types for variables in python as the interpreter itself predicts the variable data type based on the value assigned to that variable. The int data type in python simply the same as the signed integer. A signed integer is a 32-bit integer in the range of -(2^31) = -2147483648 to (2^31) - 1=2147483647 which contains positive or negative numbers. It is represented in two's complement notation. An unsigned integer is a 32-bit non-negative integer(0 or positive numbers) in the range of 0 to 2^32-1. So, in this article let us know how to convert signed integer to unsigned integer in python. Example 1: Add 2^32(or 1 << 32) to a signed integer to convert it to an unsigned integer Python3 signed_integer = -100 # Adding 2^32 to convert signed to unsigned integer unsigned_integer = signed_integer+2**32 print(unsigned_integer) print(type(unsigned_integer)) Output: 4294967196 <class 'int'> Example 2: Using Bitwise left shift(<<) operator Bitwise left shift: It performs bit manipulation by shifting the left operand bits of the number to the left and fills 0 on voids left as a result. For example, x << y Left shifts the integer 'x' with 'y' integer by y places. It is the same as multiplying x with 2 raised to the power of y(2**y). Python3 signed_integer = -1 # Adding 1<<32 to convert signed to # unsigned integer unsigned_integer = signed_integer+(1 << 32) print(unsigned_integer) Output: 4294967295 Example 3: Python3 signed_integer = -10 # Adding 1<<32 to convert signed to # unsigned integer unsigned_integer = signed_integer+(1 << 32) print(unsigned_integer) Output: 4294967286 Comment More infoAdvertise with us Next Article How to convert signed to unsigned integer in Python ? G greeshmanalla Follow Improve Article Tags : Python python-basics Practice Tags : python Similar Reads How to convert string to integer in Python? In Python, a string can be converted into an integer using the following methods : Method 1: Using built-in int() function: If your string contains a decimal integer and you wish to convert it into an int, in that case, pass your string to int() function and it will convert your string into an equiv 3 min read Convert Hex String To Integer in Python Hexadecimal representation is commonly used in computer science and programming, especially when dealing with low-level operations or data encoding. In Python, converting a hex string to an integer is a frequent operation, and developers have multiple approaches at their disposal to achieve this tas 2 min read How to Convert Bytes to Int in Python? Converting bytes to integers in Python involves interpreting a sequence of byte data as a numerical value. For example, if you have the byte sequence b'\x00\x01', it can be converted to the integer 1.Using int.from_bytes()int.from_bytes() method is used to convert a byte object into an integer. It a 3 min read How to Convert Int to Bytes in Python? The task of converting an integer to bytes in Python involves representing a numerical value in its binary form for storage, transmission, or processing. For example, the integer 5 can be converted into bytes, resulting in a binary representation like b'\x00\x05' or b'\x05', depending on the chosen 2 min read How to convert Float to Int in Python? In Python, you can convert a float to an integer using type conversion. This process changes the data type of a value However, such conversions may be lossy, as the decimal part is often discarded.For example:Converting 2.0 (float) to 2 (int) is safe because here, no data is lost.But converting 3.4 5 min read Like