Skip to content

signed integer

A signed integer is a whole number that can hold a negative, zero, or positive value, with part of its binary encoding reserved to record the sign.

Hardware needs a fixed way to encode the sign, since a register stores only bits and not a leading minus symbol. Three classic schemes exist:

  • Sign-magnitude, which sets the most significant bit to mark a negative value.
  • Ones’ complement, which negates a number by inverting every bit.
  • Two’s complement, which inverts the bits and then adds one.

Modern processors, such as x86 and ARM, use two’s complement almost universally, because it gives a single representation of zero and lets one set of circuits handle both addition and subtraction. The most significant bit carries a negative weight, so an n-bit value spans the asymmetric range from -2ⁿ⁻¹ to 2ⁿ⁻¹ - 1. An 8-bit signed integer therefore runs from -128 to 127.

Because the width is fixed, arithmetic that crosses the range boundary wraps around silently, an effect known as integer overflow. Python’s int sidesteps this by growing to arbitrary precision instead of using a fixed width.

Bitwise Operators in Python

Tutorial

Bitwise Operators in Python

Learn how to use Python's bitwise operators to manipulate individual bits of data at the most granular level.

intermediate python

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated June 22, 2026 • Reviewed by Leodanis Pozo Ramos