2.Data Representation & Boolean Algebra
Higher Secondary · Computer Science · Science Stream

Data Representation and Boolean Algebra

How computers store numbers, text and multimedia in binary form, and how George Boole's logic of AND, OR and NOT lets computers make decisions.

2.1 – 2.2 · Live Tool

Number System Converter

Computers use binary internally; humans use decimal; hexadecimal is a compact shorthand for binary. Type a value in any base and see it converted instantly.

Base Converter

● live
Binary · base 2
—
Decimal · base 10
—
Hexadecimal · base 16
—
Only the digits valid for the chosen base are accepted (binary: 0–1, decimal: 0–9, hex: 0–9 & A–F). This chapter restricts its discussion to binary, decimal and hexadecimal.
2.3 · Live Tool

Binary Adder & Subtractor

All arithmetic inside a computer is carried out in binary, using only the digits 0 and 1. Try the rules yourself below.

Binary Adder

Enter two binary numbers (0s and 1s only).

+
10000

Binary Subtractor

Subtracts B from A directly (borrow method). A must be ≥ B.

−
0100
ABSumCarryABDifferenceBorrow
00000000
01100111
10101010
11011100
2.1

Number Systems

In a positional number system, a digit's value depends on its face value and its place value (a power of the base).

Decimal · Base 10

Digits 0–9. Not used inside computers, but essential for showing results to humans.

Binary · Base 2

Digits 0–1. Matches the ON/OFF (high/low) states of transistors in a computer's ICs.

Hexadecimal · Base 16

Digits 0–9, A–F. Each hex digit = a 4-bit binary group — a compact shorthand for binary.

(5398)10 = 5×10³ + 3×10² + 9×10¹ + 8×10⁰ = 5000 + 300 + 90 + 8 = 5398
(11010)2 = 1×2⁴ + 1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 16 + 8 + 0 + 2 + 0 = 26
(10A)16 = 1×16² + 0×16¹ + A×16⁰ = 256 + 0 + 10 = 266

The digit with the highest place value is the Most Significant Digit/Bit (MSD/MSB); the one with the lowest is the Least Significant Digit/Bit (LSD/LSB).

2.4.1

Representation of Integers

Using an 8-bit word length, computers represent signed integers with three common methods.

Sign & Magnitude

MSB = sign (0 positive, 1 negative); remaining 7 bits = magnitude.

11101101

= −109

1's Complement

Positive numbers stay as-is; for negatives, invert every bit of the positive form.

10100011

= −92

2's Complement

1's complement + 1. Used by modern computers — no separate "negative zero".

10110101

= −75

Why 2's Complement Wins

DecimalSign & Magnitude1's Complement2's Complement
+0000000000
−0100111—
−1101110111
−4——100

Sign & Magnitude and 1's Complement both have a wasted "negative zero" representation. 2's Complement eliminates it, and lets computers use the same hardware to add and subtract — by adding the complement of the subtrahend.

Floating Point Numbers

A real number is stored as N = (−1)sign × (1.mantissa) × 2exponent — like scientific notation, but base 2. The IEEE 754 standard defines Single precision (32-bit: 1 sign + 8 exponent + 23 mantissa) and Double precision (64-bit: 1 sign + 11 exponent + 52 mantissa).

2.5 – 2.6

Boolean Algebra & Logic Gates

George Boole's algebra of True (1) and False (0) is the logical foundation of every digital circuit and every conditional statement in a program.

OR ( + )

Logical addition — output is 1 if any input is 1.

AND ( . )

Logical multiplication — output is 1 only if all inputs are 1.

NOT ( ‾ )

Logical negation — a unary operator that flips the single input.

Truth Tables

ABA + B (OR)A . B (AND)Ā (NOT A)
00001
01101
10100
11110

Universal Gates

NAND ( Ā.B̄ style )

AND followed by NOT. Output is 0 only when all inputs are 1 — otherwise 1.

NOR

OR followed by NOT. Output is 1 only when all inputs are 0 — otherwise 0.

NAND and NOR are called Universal Gates — any logic gate (AND, OR, NOT) can be built using only NAND gates, or only NOR gates. This simplifies manufacturing, since a chip only needs one type of gate.

De Morgan's Theorems

First Theorem

(A + B)‾ = Ā . B̄ — the complement of a sum equals the product of the complements.

Second Theorem

(A . B)‾ = Ā + B̄ — the complement of a product equals the sum of the complements.

Key Boolean Laws

LawStatement 1Statement 2
IdempotentA + A = AA . A = A
CommutativeA + B = B + AA . B = B . A
AssociativeA+(B+C)=(A+B)+CA.(B.C)=(A.B).C
DistributiveA.(B+C)=A.B+A.CA+(B.C)=(A+B).(A+C)
AbsorptionA+(A.B)=AA.(A+B)=A
Let Us Do

Quick Recap

Tap a question to reveal the answer.

Why does binary matter more than decimal inside a computer?

Computer processors are built from transistors that have two electronic states — high (ON) and low (OFF) — naturally represented by 1 and 0. Binary is the system computers actually process internally; decimal and hexadecimal are for human convenience.

Why is hexadecimal useful even though computers don't use it internally?

Each hexadecimal digit represents exactly 4 binary bits (since 2⁴ = 16), so long binary numbers can be written in a much shorter, more readable form — useful for memory addresses and colour codes.

What problem does 2's Complement solve that Sign & Magnitude and 1's Complement don't?

Both Sign & Magnitude and 1's Complement have two representations for zero (+0 and −0), wasting a bit pattern. 2's Complement has only one representation for zero, and lets addition hardware handle subtraction too.

What are the three parts of an IEEE 754 floating-point number?

Sign bit (positive/negative), Exponent (position of the binary point), and Mantissa (the actual significant digits of the number).

State De Morgan's two theorems.

(A + B)‾ = Ā . B̄ — the complement of a sum is the product of the complements. (A . B)‾ = Ā + B̄ — the complement of a product is the sum of the complements.

Why are NAND and NOR called "Universal Gates"?

Because any basic logic gate — AND, OR, or NOT — can be constructed using only NAND gates, or only NOR gates. This simplifies circuit manufacturing since only one gate type is needed.

How does Unicode improve on ASCII?

ASCII (7-bit, later 8-bit extended) can represent at most 256 characters — enough for English but not the world's scripts. Unicode assigns a unique code point to every character across all languages, symbols and emojis, and is commonly encoded as UTF-8, UTF-16 or UTF-32.