Skip to content
Topic 03 8 min read

Number Systems & Data Representation

Representation of Data

Binary, octal, hexadecimal and decimal are positional number systems that write the same integer value with different radices. These notes cover place-value conversion, arithmetic in non-decimal bases, BCD and excess-3 codes, the three signed-integer formats, and the character and storage standards — ASCII, EBCDIC, Unicode, bits and bytes — that give bit patterns meaning.

01

Positional notation and place value

  • A base-b numeral uses digits 0 to b−1; position i from the right carries weight b^i.
  • Decimal 935 = 9×10² + 3×10¹ + 5×10⁰.
  • Binary 1011₂ = 8 + 0 + 2 + 1 = 11₁₀; hexadecimal 2F₁₆ = 2×16 + 15 = 47₁₀.
  • Fractional digits use negative powers: 0.101₂ = 1/2 + 1/8 = 0.625₁₀.
  • Hex digits A–F stand for 10–15; 0x2F, 2F₁₆ and 47₁₀ are the same value.
  • The same digits differ by base: 10₂ = 2, 10₈ = 8, 10₁₆ = 16.
Positional notation and place value
Position:    3    2    1    0
Weight 2^:   8    4    2    1
Binary:      1    0    1    1   = 8 + 0 + 2 + 1 = 11

Position:    1    0   -1   -2
Weight 2^:   2    1   1/2  1/4
Binary:      1    0    1    0   = 2 + 0 + 0.5 + 0 = 2.5

Subscript shows the base: 1011_2, 2F_16, 47_10
02

Base conversion

  • Decimal to base b: divide by b repeatedly; the remainders, read bottom to top, are the digits.
  • Base b to decimal: multiply each digit by its place weight b^i and add the products.
  • Binary to octal: group 3 bits from the binary point; binary to hex: group 4 bits.
  • Pad the first and last groups with zeros; 1001 1100₂ = 9C₁₆ = 234₈.
  • Decimal 156 = 1001 1100₂; decimal 45 = 0010 1101₂ = 2D₁₆.
  • Check by expanding the result: 234₈ = 2×64 + 3×8 + 4 = 156₁₀.
Decimal, binary, octal, hexadecimal and BCD equivalents
DecimalBinaryOctalHex8421 BCD
00000000000
10001110001
50101550101
810001081000
10101012A0001 0000
15111117F0001 0101
161 000020100001 0110
311 1111371F0011 0001
1561001 11002349C0001 0101 0110
2551111 1111377FF0010 0101 0101
Base conversion
156 ÷ 2 = 78  r 0
 78 ÷ 2 = 39  r 0
 39 ÷ 2 = 19  r 1
 19 ÷ 2 =  9  r 1
  9 ÷ 2 =  4  r 1
  4 ÷ 2 =  2  r 0
  2 ÷ 2 =  1  r 0
  1 ÷ 2 =  0  r 1   -> read up: 1001 1100

1001 1100 = 9C hex
1001 1100 = 010 011 100 = 234 octal

Expand: 234_8 = 2×64 + 3×8 + 4 = 156
03

Binary, octal and hexadecimal arithmetic

  • Add column by column and carry 1 when a column sum reaches the base.
  • Binary: 1+1 = 10₂ (write 0, carry 1); 1+1+1 = 11₂ (write 1, carry 1).
  • Octal: 7+1 = 10₈; a borrow adds 8 to the current column.
  • Hex: F+1 = 10₁₆; convert A–F to 10–15 before adding; a borrow adds 16.
  • Binary subtraction borrows 2: 1101₂ − 0110₂ = 0111₂ (13 − 6 = 7).
  • Binary multiplication is shift-and-add; multiplying by 2 appends a 0.
  • Verify every result by converting operands and answer to decimal.
Binary, octal and hexadecimal arithmetic
Binary addition        Octal addition        Hex addition
  1 1 1  carry           1 1 carry            1 carry
  1 0 1 1               1 7                  2 A
+ 0 1 1 0             + 2 5                + 1 7
---------             -------              -------
1 0 0 0 1             4 4                  4 1
(11 + 6 = 17)         (15 + 21 = 36)       (42 + 23 = 65)

Binary subtraction     Octal subtraction     Hex subtraction
  1 1 0 1               5 2                  3 C
- 0 1 1 0             - 2 7                - 1 F
---------             -------              -------
  0 1 1 1               2 3                  1 D
(13 - 6 = 7)          (42 - 23 = 19)       (60 - 31 = 29)
04

BCD and excess-3

  • 8421 BCD stores each decimal digit in a 4-bit nibble with weights 8, 4, 2, 1.
  • Patterns 1010–1111 are invalid in BCD; 259₁₀ = 0010 0101 1001.
  • BCD addition: if a nibble sum exceeds 9 or a carry leaves the nibble, add 0110 to correct it.
  • Example: 8 + 5 gives 1000 + 0101 = 1101; add 0110 → 1 0011, i.e. 13.
  • Excess-3 adds 0011 to each digit’s BCD code: 0 → 0011, 4 → 0111, 9 → 1100.
  • Excess-3 is self-complementing: inverting its bits gives the code for 9 − d.
  • BCD uses 4 bits per digit, so it is not the compact binary encoding of the integer.
Decimal digits in 8421 BCD and excess-3
Decimal8421 BCDExcess-3
000000011
100010100
200100101
300110110
401000111
501011000
601101001
701111010
810001011
910011100
BCD and excess-3
259 in 8421 BCD:  0010 0101 1001
407 in excess-3:  4 -> 0111, 0 -> 0011, 7 -> 1010
                  => 0111 0011 1010

BCD addition 8 + 5:
   1000
 + 0101
 ------
   1101   invalid BCD digit (> 1001)
 + 0110   add correction
 ------
 1 0011   = 13 (carry 1, digit 3)

Excess-3 self-complement:
 4 = 0111 -> invert -> 1000 = excess-3 for 5, and 9 - 4 = 5
05

Signed numbers: sign-magnitude, 1’s and 2’s complement

  • Unsigned n bits span 0 to 2ⁿ−1; 8 bits span 0–255.
  • Sign-magnitude: leftmost bit is the sign (0 = +, 1 = −), remaining bits are magnitude; two zeros.
  • 1’s complement: invert every bit of the magnitude; two zeros; addition needs end-around carry.
  • 2’s complement: invert every bit and add 1; one zero; subtract by adding the 2’s complement.
  • The 2’s complement sign bit has weight −2ⁿ⁻¹: 1000 0000 = −128 in 8 bits.
  • Ranges: sign-magnitude and 1’s complement −(2ⁿ⁻¹−1) to +(2ⁿ⁻¹−1); 2’s complement −2ⁿ⁻¹ to 2ⁿ⁻¹−1.
  • Form −45: +45 = 0010 1101 → invert = 1101 0010 → add 1 = 1101 0011.
8-bit signed representations
ValueSign-magnitude1’s complement2’s complement
+50000 01010000 01010000 0101
−51000 01011111 10101111 1011
+00000 00000000 00000000 0000
−01000 00001111 1111none (0000 0000 = +0)
+1270111 11110111 11110111 1111
−1271111 11111000 00001000 0001
−128not representablenot representable1000 0000
Signed numbers: sign-magnitude, 1’s and 2’s complement
+45        = 0010 1101
1's comp   = 1101 0010
2's comp   = 1101 0011  = -45

Check: -128 + 64 + 16 + 2 + 1 = -45
Unsigned reading of 1101 0011 = 211
06

Characters, bits, bytes and word size

  • 1 bit = one binary digit; 1 nibble = 4 bits; 1 byte = 8 bits.
  • ASCII is a 7-bit code for 128 characters: A = 65, a = 97, 0 = 48.
  • EBCDIC is an 8-bit IBM mainframe code; its letters are not contiguous.
  • Unicode assigns a code point to every character; UTF-8 encodes 1–4 bytes and matches ASCII below 128.
  • Word size is the number of bits a CPU handles at once, e.g. 8, 16, 32 or 64.
  • An n-bit field has 2ⁿ patterns: 8 bits = 256, 16 bits = 65,536.
  • Storage: 1 KiB = 1024 B, 1 MiB = 1024 KiB, 1 GiB = 1024 MiB.
Character codes and storage units
Code / unitSizeExample
ASCII7 bits, 128 codesA = 65 = 100 0001
EBCDIC8 bits, 256 codesA = 193 = 1100 0001
Unicodecode points to U+10FFFFU+0041 = A
UTF-81–4 bytes per code pointA = 41₁₆ (1 byte)
Byte8 bits256 values
WordCPU register width32 or 64 bits

Exam points

  • Binary 1011 0110₂ = B6₁₆ = 266₈ = 182₁₀.
  • Decimal 156 = 1001 1100₂ = 234₈ = 9C₁₆.
  • 8421 BCD for 259 is 0010 0101 1001; excess-3 for 4 is 0111.
  • In 8-bit 2’s complement, −45 = 1101 0011 and the range is −128 to +127.
  • The 1’s complement of 0000 0101 is 1111 1010; adding 1 gives the 2’s complement 1111 1011.
  • A byte is 8 bits; ASCII A = 65, a = 97, 0 = 48; UTF-8 is ASCII-compatible.

Key terms

Radix
The base of a positional number system; it fixes the digit set 0 to b−1 and the place weights b^i.
Two’s complement
An n-bit signed encoding in which a negative value is the bitwise inverse of its magnitude plus 1; its range is −2ⁿ⁻¹ to 2ⁿ⁻¹−1 and it has one zero.
BCD
Binary-Coded Decimal: each decimal digit is stored as a 4-bit 8421 code, and the six patterns 1010–1111 are unused.

Check yourself

Quick check

0 / 2 answered
01

What is 2A₁₆ + 17₁₆?

02

Which 8-bit pattern represents −5 in 2’s complement?

IT Fundamentals · Computer organization, memory, number systems, Boolean algebra, microprocessors, software, and MS Office.