Introduction to Information Science and Technology

SI100B · Electrical Engineering

Lecture 3: Number Systems

Xin Lou

School of Information Science and Technology · Fall 2026
Where We Are

Course Overview

Diagram
Today:Number Systems
Every layer stores its data as bits (0s and 1s).
SI100B · EE | Lecture 3: Number Systems
1 / 60
Where We Are

Running a Large Model

SI100B · EE | Lecture 3: Number Systems
2 / 60
Positional Number Systems

Everything Is Bits

SI100B · EE | Lecture 3: Number Systems
3 / 60
Positional Number Systems

Decimal Numbers

(456)_{10} = 4\times 10^2 + 5\times 10^1 + 6\times 10^0

(3705.86)_{10} = 3\times 10^3 + 7\times 10^2 + 0\times 10^1 + 5\times 10^0 + 8\times 10^{-1} + 6\times 10^{-2}

Decimal uses 10 symbols (0–9); digits right of the point have negative powers of 10.

SI100B · EE | Lecture 3: Number Systems
4 / 60
Positional Number Systems

Binary Numbers

SI100B · EE | Lecture 3: Number Systems
5 / 60
Positional Number Systems

Leibniz and Binary, 1703

1703

Leibniz published binary arithmetic: only the digits 0 and 1.

SI100B · EE | Lecture 3: Number Systems
6 / 60
Positional Number Systems

Unsigned Integers

SI100B · EE | Lecture 3: Number Systems
7 / 60
Positional Number Systems

Pac-Man Level 256, 1980

256

255 + 1 wraps to 0 in 8 bits. Level 256 breaks the screen.

SI100B · EE | Lecture 3: Number Systems
8 / 60
Positional Number Systems

Hexadecimal

SI100B · EE | Lecture 3: Number Systems
9 / 60
Positional Number Systems

Fixed-Point Numbers

An integer with a fixed scaling factor (r^{-M}); hardware prefers fixed point for higher speed and lower cost.

SI100B · EE | Lecture 3: Number Systems
10 / 60
Negative Numbers

Negative Numbers: Three Approaches

Sign and magnitude

One’s complement

Two’s complement

All three represent positive numbers in the same way.

SI100B · EE | Lecture 3: Number Systems
11 / 60
Negative Numbers

Sign and Magnitude

SI100B · EE | Lecture 3: Number Systems
12 / 60
Negative Numbers

Sign and Magnitude: Addition Fails

columns: [{width: 0.18}, {width: 0.30}, {width: 0.38}]
Operation Direct binary addition Compare and subtract
4 + (−3) = 1 0100 + 1011 = 1111 ( − 7) 0100 - 0011 = 0001 ( + 1)
 − 4 + 3 =  − 1 1100 + 0011 = 1111 ( − 7) -(0100 - 0011) = 1001 ( − 1)

Direct addition fails (4 - 3 \neq 4 + (-3)); hardware must compare signs and magnitudes.

SI100B · EE | Lecture 3: Number Systems
13 / 60
Negative Numbers

One’s Complement

\underbrace{0111}_{+7} \;\xrightarrow{\text{invert}}\; \underbrace{1000}_{-7}

Invert every bit to negate; +0 = \texttt{0000} and -0 = \texttt{1111} still give two zeros.

SI100B · EE | Lecture 3: Number Systems
14 / 60
Negative Numbers

One’s Complement: End-Around Carry

columns: [{width: 0.22}, {width: 0.34}, {width: 0.30}]
Operation 4-bit addition End-around carry
4 + 3 = 7 0100 + 0011 = 0111 none ( + 7)
4 + (−3) = 1 0100 + 1100 = 1 0000 0000 + 1 = 0001 ( + 1)
 − 4 + 3 =  − 1 1011 + 0011 = 1110 none ( − 1)

If addition produces a carry out, add 1 back to the least significant bit (end-around carry).

SI100B · EE | Lecture 3: Number Systems
15 / 60
Negative Numbers

Two’s Complement Wheel

SI100B · EE | Lecture 3: Number Systems
16 / 60
Negative Numbers

Two’s Complement: Invert and Add One

\underbrace{0111}_{+7} \;\xrightarrow{\text{invert}}\; 1000 \;\xrightarrow{+1}\; \underbrace{1001}_{-7}

Invert the bits and add one to form the negative.

SI100B · EE | Lecture 3: Number Systems
17 / 60
Negative Numbers

Two’s Complement: Bit Weights

\text{value}=-b_{n-1}2^{n-1}+\sum_{i=0}^{n-2}b_i2^i \qquad (b_i\in\{0,1\})

(1001)_2=-8+1=-7

The most significant bit has negative weight.

SI100B · EE | Lecture 3: Number Systems
18 / 60
Negative Numbers

Same Bits, Two Readings

SI100B · EE | Lecture 3: Number Systems
19 / 60
Negative Numbers

Integer Ranges

SI100B · EE | Lecture 3: Number Systems
20 / 60
Negative Numbers

Gangnam Style, 2014

2014

Gangnam Style views passed the largest signed 32-bit integer.

SI100B · EE | Lecture 3: Number Systems
21 / 60
Overflow and Sign Extension

Subtraction Is Addition

SI100B · EE | Lecture 3: Number Systems
22 / 60
Overflow and Sign Extension

Overflow

SI100B · EE | Lecture 3: Number Systems
23 / 60
Overflow and Sign Extension

Positive + Positive

columns: [{width: 0.28}, {width: 0.20}, {width: 0.14}, {width: 0.24}]
5-bit addition Mathematical sum 5-bit reading Carry into / out of MSB
01011 + 01001 = 10100 11 + 9 = 20  − 12 1/0
00011 + 01001 = 01100 3 + 9 = 12 12 0/0

Two positive numbers overflow when the sum is negative.

SI100B · EE | Lecture 3: Number Systems
24 / 60
Overflow and Sign Extension

Negative + Negative

columns: [{width: 0.28}, {width: 0.20}, {width: 0.14}, {width: 0.24}]
5-bit addition Mathematical sum 5-bit reading Carry into / out of MSB
10011 + 11001 = 01100  − 13 + (−7) =  − 20 12 0/1
11011 + 11001 = 10100  − 5 + (−7) =  − 12  − 12 1/1

Two negative numbers overflow when the sum is nonnegative.

SI100B · EE | Lecture 3: Number Systems
25 / 60
Overflow and Sign Extension

Positive + Negative

\underbrace{01001}_{+9}+\underbrace{11011}_{-5} =\underbrace{00100}_{+4} \qquad (\text{5 bits})

Adding numbers of opposite signs cannot overflow.

SI100B · EE | Lecture 3: Number Systems
26 / 60
Overflow and Sign Extension

Overflow Detection

\boxed{\text{overflow}\;\Longleftrightarrow\; \text{carry into MSB}\ne\text{carry out of MSB}}

For signed two’s-complement addition at a fixed width.

SI100B · EE | Lecture 3: Number Systems
27 / 60
Overflow and Sign Extension

Sign Extension

columns: [{width: 0.26}, {width: 0.38}, {width: 0.2}]
4-bit value Extend to 6 bits Value
0101 000101  + 5
1011 111011  − 5

Copy the sign bit to the left; the value stays the same.

SI100B · EE | Lecture 3: Number Systems
28 / 60
Overflow and Sign Extension

Sign Extension: Different Widths

columns: [{width: 0.28}, {width: 0.44}, {width: 0.14}]
Extend before adding 6-bit addition Result
 − 5: 1011 → 111011 111011 + 010010 = 001101 13

Discard the carry out; -5 + 18 = 13.

SI100B · EE | Lecture 3: Number Systems
29 / 60
Overflow and Sign Extension

Boeing 787: 248 Days, 2015

248

A counter overflow after 248 days could cut AC power.

SI100B · EE | Lecture 3: Number Systems
30 / 60
Overflow and Sign Extension

The Year 2038 Problem

SI100B · EE | Lecture 3: Number Systems
31 / 60
Floating-Point Numbers

Scientific Notation

SI100B · EE | Lecture 3: Number Systems
32 / 60
Floating-Point Numbers

Floating Point: Three Fields

SI100B · EE | Lecture 3: Number Systems
33 / 60
Floating-Point Numbers

Biased Exponent

\text{stored exponent}=\text{exponent}+127

-3+127=124=(01111100)_2

FP32 stores the exponent with a bias of 127.

SI100B · EE | Lecture 3: Number Systems
34 / 60
Floating-Point Numbers

The Hidden One and Fraction

1.011_2=1+2^{-2}+2^{-3}=1.375

For a normal number, the leading 1 is implicit; the fraction field stores 01100…0.

SI100B · EE | Lecture 3: Number Systems
35 / 60
Floating-Point Numbers

Example: 6.5

SI100B · EE | Lecture 3: Number Systems
36 / 60
Floating-Point Numbers

Example: 6.5 in FP32

6.5=110.1_2=1.101_2\times2^2

columns: [{width: 0.2}, {width: 0.24}, {width: 0.40}]
Sign (1 bit) Exponent (8 bits) Fraction (23 bits)
0 10000001 10100000000000000000000

The exponent is 2+127=129; the leading 1 is implicit.

SI100B · EE | Lecture 3: Number Systems
37 / 60
Floating-Point Numbers

William Kahan and IEEE 754, 1985

1985

IEEE 754: the standard for floating-point numbers and arithmetic.

SI100B · EE | Lecture 3: Number Systems
38 / 60
Floating-Point Numbers

Range and Precision

SI100B · EE | Lecture 3: Number Systems
39 / 60
Floating-Point Numbers

Ariane 5 Flight 501, 1996

1996

A 64-bit float overflowed a 16-bit integer.

SI100B · EE | Lecture 3: Number Systems
40 / 60
Floating-Point Numbers

0.1 + 0.2

SI100B · EE | Lecture 3: Number Systems
41 / 60
Floating-Point Numbers

Patriot Missile, 1991

1991

Truncating 0.1 in binary: a 0.34 s error after 100 hours.

SI100B · EE | Lecture 3: Number Systems
42 / 60
Floating-Point Numbers

Pentium FDIV Bug, 1994

1994

Five wrong table entries; Intel took a $475 million charge.

SI100B · EE | Lecture 3: Number Systems
43 / 60
Floating-Point Numbers

Fixed-Point vs. Floating-Point: Dynamic Range

columns: [{width: 0.22}, {width: 0.32}, {width: 0.32}]
32-bit format Smallest / Largest positive Dynamic range
Fixed point 1 × 2−N to (232−1) × 2−N 20log10(232−1) ≈ 192 dB
Floating point  ≈ 1.18 × 10−38 to 3.40 × 1038  ≈ 1529 dB

Floating point trades hardware simplicity for a vastly wider dynamic range.

SI100B · EE | Lecture 3: Number Systems
44 / 60
Floating-Point Numbers

Fixed-Point vs. Floating-Point: Trade-offs

columns: [{width: 0.16}, {width: 0.70}]
Format Characteristics & example
Fixed point Limited dynamic range, fast, low power (e.g., filter coefficient quantization)
Floating point High dynamic range, complex, slow

Hardware uses fixed point when range is bounded and cost or power matters.

SI100B · EE | Lecture 3: Number Systems
45 / 60
Number Formats for AI

Bits per Parameter

SI100B · EE | Lecture 3: Number Systems
46 / 60
Number Formats for AI

Model Size by Format

SI100B · EE | Lecture 3: Number Systems
47 / 60
Number Formats for AI

Fewer Bits per Number

SI100B · EE | Lecture 3: Number Systems
48 / 60
Number Formats for AI

DeepSeek-V3: FP8 Training, 2024

2024

DeepSeek-V3 reported FP8 mixed-precision training.

SI100B · EE | Lecture 3: Number Systems
49 / 60
Number Formats for AI

Same Number, Different Formats

SI100B · EE | Lecture 3: Number Systems
50 / 60
Number Formats for AI

All 16 FP4 Values

SI100B · EE | Lecture 3: Number Systems
51 / 60
Number Formats for AI

Blackwell: FP4 Inference

2025

Blackwell GPUs compute in 4-bit floating point (NVFP4).

SI100B · EE | Lecture 3: Number Systems
52 / 60
Number Formats for AI

gpt-oss: Local Models, 2025

2025

OpenAI released gpt-oss-20b and gpt-oss-120b.

SI100B · EE | Lecture 3: Number Systems
53 / 60
Wrap-Up

Key Ideas

Everything is stored as bits.

The same bits can have different meanings.

A fixed number of bits means a limited range.

Floating point uses scientific notation, with rounding.

Fewer bits per parameter means smaller models.

SI100B · EE | Lecture 3: Number Systems
54 / 60
Wrap-Up

Homework 1

Details will be announced on the course website.

SI100B · EE | Lecture 3: Number Systems
55 / 60
Wrap-Up

Next: Arithmetic

Diagram
Next:Arithmetic
How does hardware add and multiply?
SI100B · EE | Lecture 3: Number Systems
56 / 60
Backup

Backup: Why One’s Complement Works (1/2)

1111_2 - y = (2^4 - 1) - y

1111_2 - 0111_2 = 1000_2 \equiv -7_{10}

For a 4-bit positive number y, its bitwise complement equals (2^4 - 1) - y.

SI100B · EE | Lecture 3: Number Systems
57 / 60
Backup

Backup: Why One’s Complement Works (2/2)

x + ((2^4 - 1) - y) = (2^4 - 1) + (x - y)

If x < y, there is no carry and the sum is the one’s complement of x - y; if x > y, the carry triggers end-around carry (-2^4 + 1), leaving x - y; if x = y, the sum is 1111_2 (-0).

SI100B · EE | Lecture 3: Number Systems
58 / 60
Backup

Backup: Why Two’s Complement Works (1/2)

-y \equiv 2^b - y \pmod{2^b}

Adding 1 to the one’s complement (2^b - 1) - y gives 2^b - y; dropping the carry out of a b-bit adder computes \bmod\; 2^b.

SI100B · EE | Lecture 3: Number Systems
59 / 60
Backup

Backup: Why Two’s Complement Works (2/2)

x + (2^b - y) = 2^b + (x - y)

If x \ge y, the carry out (2^b) is dropped, leaving x - y; if x < y, there is no carry and 2^b - (y - x) is the two’s complement of x - y (assuming no overflow).