Mathematics.

number systems

Number Bases and Binary Representation

Foundations30 minDifficulty3 out of 10

You should know: natural numbers, integers

Overview

Positional notation represents numbers as sums of powers of a base b. Our standard system is base 10 (decimal). Binary (base 2), octal (base 8), and hexadecimal (base 16) are used in computing. In base b, the number with digits d_n d_{n-1}...d_1 d_0 represents sum_{k=0}^n d_k * b^k. Binary is fundamental to digital computing: all data is stored as bits (0 or 1). Two's complement encodes signed integers in binary.

Intuition

A number like 1101 in binary means: 1*8 + 1*4 + 0*2 + 1*1 = 13 in decimal. Each position is worth twice the previous (instead of 10x in decimal). Counting in binary: 0, 1, 10, 11, 100, 101, 110, 111, 1000... To convert decimal to binary: repeatedly divide by 2 and record remainders.

Formal Definition

Definition

Base-b representation: every non-negative integer n can be uniquely written as n = sum_{k=0}^m d_k * b^k where 0 <= d_k < b. In binary (b=2), digits are 0 or 1. Hex (b=16) uses digits 0-9, A-F. Conversion algorithm: to convert n to base b, compute n mod b (rightmost digit), then recurse on n div b. Two's complement for n-bit signed integers: represents -k as 2^n - k (flip bits and add 1).

n=k=0mdkbk,0dk<bn = \sum_{k=0}^m d_k \cdot b^k,\quad 0 \le d_k < b
Base-b representation
(1101)2=18+14+02+1=1310(1101)_2 = 1\cdot 8 + 1\cdot 4 + 0\cdot 2 + 1 = 13_{10}
Binary example
(FF)16=1516+15=25510(\mathrm{FF})_{16} = 15 \cdot 16 + 15 = 255_{10}
Hex example

Notation

NotationMeaning
(n)b(n)_bNumber n written in base b
0b11010\mathrm{b}1101Binary notation (programming)
0xFF0x\mathrm{FF}Hexadecimal notation (programming)

Theorems

Theorem 1: Uniqueness of Base-b Representation
Everypositiveintegernhasauniquerepresentationinbaseb>=2:n=dmbm+...+d1b+d0withdm!=0and0<=dk<b.Proof:existencebyrepeateddivision;uniquenessbycomparingleadingdigits.Every positive integer n has a unique representation in base b >= 2: n = d_m b^m + ... + d_1 b + d_0 with d_m != 0 and 0 <= d_k < b. Proof: existence by repeated division; uniqueness by comparing leading digits.

Worked Examples

  1. 1

    Divide repeatedly by 2, record remainders: 45 = 2*22+1, 22 = 2*11+0, 11 = 2*5+1, 5 = 2*2+1, 2 = 2*1+0, 1 = 2*0+1.

  2. 2

    Read remainders from bottom to top: 101101.

    4510=(101101)245_{10} = (101101)_2
  3. 3

    Verify: 32+8+4+1 = 45. Correct.

    132+016+18+14+02+1=451\cdot32+0\cdot16+1\cdot8+1\cdot4+0\cdot2+1 = 45

✓ Answer

45 = 101101 in binary.

Practice Problems

Easyapplication

Convert (1010 1100)_2 to hexadecimal.

Common Mistakes

Common Mistake

Confusing binary digits with the value of the number.

The binary string '1000' does NOT represent 'one thousand'. It represents 1*2^3 = 8 in decimal. The string '1000' in binary is eight; in decimal it would be one thousand. Always specify the base when ambiguous.

Quiz

What is (1111)_2 in decimal?

Historical Background

Positional notation with base 10 was developed in India (Aryabhata, 5th century AD) and transmitted to Europe via Arab mathematicians (hence 'Arabic numerals'). The Babylonians used base 60 (still seen in 60 minutes/hour, 360 degrees). Binary arithmetic was studied by Leibniz (1703) who saw it as reflecting the philosophy of creation (1 = being, 0 = nothing). George Boole (1854) developed Boolean algebra for binary logic. Shannon (1948) showed that binary logic is ideal for electronic circuits.

  1. 499

    Aryabhata uses positional decimal notation

    Aryabhata

  2. 1703

    Leibniz publishes binary arithmetic

    Gottfried Wilhelm Leibniz

  3. 1948

    Shannon establishes information theory using binary 'bits'

    Claude Shannon

Summary

  • Base-b representation: n = sum d_k * b^k with digits 0 <= d_k < b.
  • Binary (b=2): digits 0,1. Used in all digital computing.
  • Conversion: decimal -> binary by repeated division by 2.
  • Hex (b=16): 0-9,A-F. One hex digit = 4 binary bits (nibble).

References

  1. BookPetzold, C. Code: The Hidden Language of Computer Hardware and Software. Microsoft Press, 2000.