Skip to content
BetterDL

Unsigned number

Also called: unsigned, unsigned binary, unsigned integer

A binary number with no sign: every bit has a positive weight, so n bits represent the whole numbers 0 to 2ⁿ − 1.

An unsigned number is a plain binary count. Every bit has its usual positive weight, so the value can never be negative.

With n bits, the smallest pattern (all 0s) is 0 and the largest (all 1s) is 1 + 2 + 4 + … + 2ⁿ⁻¹ = 2ⁿ − 1:

  • 4 bits: 0 to 15
  • 8 bits: 0 to 255
  • 16 bits: 0 to 65,535

Unsigned numbers are used wherever negative values make no sense: memory addresses, counters, pixel brightness, array sizes.

The same bit pattern means something else as a signed number. 1111 is 15 unsigned but −1 in twos complement. An adder doesn't care: it produces the same bits either way. What differs is how you check the result. For unsigned addition, a carry out of the MSB means unsigned overflow: the true sum needed one more bit. See signed vs unsigned.

1
128
1
64
1
32
1
16
1
8
1
4
1
2
1
1

Worked example

Example

The range of 6-bit unsigned numbers

Find the smallest and largest values, then test whether 64 fits.

  1. 1.

    Smallest: 000000 = 0.

  2. 2.

    Largest: 111111 = 32 + 16 + 8 + 4 + 2 + 1 = 63 = 2⁶ − 1.

  3. 3.

    There are 2⁶ = 64 patterns, covering 0 to 63.

  4. 4.

    So 64 doesn't fit in 6 unsigned bits. It needs 7: 1000000.

Common mistakes

  • Saying n bits reach 2ⁿ. The largest value is 2ⁿ − 1.

  • Applying the sign rule to unsigned numbers. An unsigned 1000 is 8, not negative.

  • Using the signed overflow test for unsigned numbers. For unsigned addition, overflow is simply carry-out = 1.

Practice Unsigned number

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Unsigned number is taught in Number Systems and Adders and ALUs.