Number Systems, Bases, and Counting -- IFT 510 Ch. 3 -- Study Notes
offline

Source: Foundations of Computer Science, Ch. 3 (Sections 3.0 -- 3.2)

Tags: number systems, base conversion, binary, octal, hexadecimal, positional notation, counting in bases, bit, byte, word, IFT 510, Purdue

Difficulty: Introductory

Prerequisites: Basic arithmetic. No prior computer science knowledge needed.


Big Picture

This is one of the foundational topics in computer science. Every piece of data your computer handles, from text to images to instructions, is stored as binary numbers. Understanding how number systems work across different bases is essential for everything that follows in this course: data formats, memory addressing, machine instructions, and signed/unsigned arithmetic. If you are coming in cold, start here. The decimal system you already know is just one instance of a general pattern, and the same logic applies to binary (base 2), octal (base 8), and hexadecimal (base 16).


TL;DR

Humans use base 10 because we have ten fingers. Computers use base 2 because their circuits have two states: on and off. Any number can be represented equivalently in any base. Converting between bases is a mechanical process of multiplying digit values by positional weights. Hexadecimal (base 16) is widely used as a compact shorthand for binary.


Key Terms

Base (radix)

The number of distinct digits available in a number system, including zero. Base 10 has digits 0 through 9. Base 2 has digits 0 and 1. Base 16 has digits 0 through F. In simple terms, the base tells you how many symbols you get to work with before you need a new column.

Binary (base 2)

The number system used internally by all computers. Only two digits exist: 0 and 1. Think of it as the language your hardware speaks natively.

Bit (binary digit)

A single digit in a binary number, either 0 or 1. The smallest unit of data in computing. In simple terms, one bit is one yes-or-no decision.

Byte

A group of 8 bits. Can represent 256 different values (0 through 255). Think of it as the standard "chunk" of data most systems work with.

Halfword

A group of 16 bits (2 bytes).

Word

A group of 32 bits (4 bytes) in most modern contexts.

Doubleword

A group of 64 bits (8 bytes).

Octal (base 8)

A number system using digits 0 through 7. Each octal digit maps to exactly 3 binary digits. In simple terms, a shorthand for binary that groups bits into threes.

Hexadecimal (base 16)

A number system using digits 0 through 9 and letters A through F (where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15). Each hex digit maps to exactly 4 binary digits. In simple terms, the most common shorthand for binary in modern computing. HTML colour codes (#FF00AA) are hex.

Weight (of a digit position)

The multiplication factor for a digit based on its position. In any base B, the weight of position n (counting from the right, starting at 0) is B to the power n. In simple terms, it tells you "how much" that column is worth.

Positional notation

The system where a digit's value depends on where it sits in the number. The digit 3 in "300" means something different from the 3 in "30".


Core Content

How Counting Works in Any Base

The counting process is identical in every base. You cycle through all available digits in the rightmost column. When you run out of digits, you reset that column to 0 and add 1 to the next column left.

  • In base 10: after 9 comes 10 (reset the ones, carry to the tens)

  • In base 2: after 1 comes 10 (reset the ones, carry to the twos)

  • In base 8: after 7 comes 10 (reset the ones, carry to the eights)

  • In base 16: after F comes 10 (reset the ones, carry to the sixteens)

The "10" in any base simply means "one group of [base] and zero extras."

Positional Weights and Expanded Form

Every number in base B can be written as a sum of each digit multiplied by its positional weight.

The number 527 in base 10:

5 x 10^2  +  2 x 10^1  +  7 x 10^0
= 500 + 20 + 7
= 527

The number 624 in base 8:

6 x 8^2  +  2 x 8^1  +  4 x 8^0
= 6 x 64 + 2 x 8 + 4 x 1
= 384 + 16 + 4
= 404 (in base 10)

The number 2A4F in base 16:

2 x 16^3  +  A x 16^2  +  4 x 16^1  +  F x 16^0
= 2 x 4096 + 10 x 256 + 4 x 16 + 15 x 1
= 8192 + 2560 + 64 + 15
= 10831 (in base 10)

Counting in Base 2

Binary

Expanded form

Decimal

0

0 x 2^0

0

1

1 x 2^0

1

10

1 x 2^1

2

11

1 x 2^1 + 1 x 2^0

3

100

1 x 2^2

4

101

1 x 2^2 + 1 x 2^0

5

110

1 x 2^2 + 1 x 2^1

6

111

1 x 2^2 + 1 x 2^1 + 1 x 2^0

7

1000

1 x 2^3

8

1001

1 x 2^3 + 1 x 2^0

9

1010

1 x 2^3 + 1 x 2^1

10

Range Formula

For n digits in base B, the total number of representable values is:

range = B^n
  • 2 decimal digits: 10^2 = 100 values (0 through 99)

  • 3 hex digits: 16^3 = 4096 values (0 through FFF, or 0 through 4095)

  • 8 bits: 2^8 = 256 values

  • 16 bits: 2^16 = 65,536 values (64K)

  • 32 bits: 2^32 = 4,294,967,296 values (roughly 4 billion, or 4G)

Quick Estimation Trick for Binary

Since 2^10 is approximately 1000 (1024, to be precise), you can estimate binary ranges by breaking the bit count into groups of 10.

  • 20 bits: 2^10 x 2^10 = 1K x 1K = 1M (about a million)

  • 32 bits: 2^10 x 2^10 x 2^10 x 2^2 = 1K x 1K x 1K x 4 = 4G

Approximately 3.3 bits are needed per decimal digit (because 2^3.3 is roughly 10).

Common Bit Widths and Their Ranges

Bits

Approximate range

1

2 (0 and 1)

4

16 (0 to 15)

8

256

10

1,024 (1K)

16

65,536 (64K)

20

1,048,576 (1M)

32

~4.3 billion (4G)

64

~1.6 x 10^19

Hexadecimal Digit Reference

Hex

Decimal

Binary

0

0

0000

1

1

0001

2

2

0010

3

3

0011

4

4

0100

5

5

0101

6

6

0110

7

7

0111

8

8

1000

9

9

1001

A

10

1010

B

11

1011

C

12

1100

D

13

1101

E

14

1110

F

15

1111


Real-World Applications

HTML/CSS colours like #FF5733 are three hexadecimal pairs representing red, green, and blue intensity. That is a 24-bit binary number written in hex for readability. When debugging network packets, reading memory dumps, or setting file permissions in Unix (chmod 755), you are working directly with non-decimal bases.


Common Misconceptions

  • Students often think "10" always means ten. It does not. "10" in any base means "one group of [base]." In binary, 10 equals two. In octal, 10 equals eight.

  • Students sometimes assume hexadecimal A through F are somehow special. They are ordinary digit symbols, just as 7 or 3. The letters are used only because we ran out of single-character Arabic numerals after 9.

  • Confusing the number of digits with the number of values: 8 bits give you 256 values, not 8. The range is always base raised to the power of the digit count.

  • Thinking that converting between bases changes the quantity. It does not. Five oranges are five oranges whether written as 5 (decimal), 101 (binary), or 5 (hex).


Why It Matters / Exam Flags

⚠️ The range formula (range = base^n) is heavily tested. Know it cold.

⚠️ Be able to convert small binary numbers to decimal by writing out the weights and summing.

⚠️ Know the hex digit-to-binary mapping (each hex digit = exactly 4 bits). This comes up repeatedly in later chapters.

⚠️ Understand that Java's short (16 bits), int (32 bits), and long (64 bits) directly relate to the ranges in this chapter.

⚠️ The estimation trick (2^10 ≈ 1000) is called out in the textbook as useful for exam quick-checks.


Quick Self-Test

1. True or false: In base 8, the digit 8 is valid. False. Base 8 uses digits 0 through 7 only.

2. Fill in the blank: 2^16 = ______ 65,536

3. True or false: The binary number 1101 equals (fill in) in decimal. 13 (8 + 4 + 0 + 1)

4. Fill in the blank: In hexadecimal, the letter C represents the decimal value ______. 12

5. True or false: A byte can represent 255 different values. False. A byte can represent 256 different values (0 through 255).


Practice Q&A

Q: What is the decimal value of the binary number 110010100?

A: 1x256 + 1x128 + 0x64 + 0x32 + 1x16 + 0x8 + 1x4 + 0x2 + 0x1 = 404

Q: What is the decimal value of the hexadecimal number 2A4F?

A: 2x4096 + 10x256 + 4x16 + 15x1 = 8192 + 2560 + 64 + 15 = 10,831

Q: How many different values can be stored in a 20-bit number?

A: 2^20 = 1,048,576 (approximately 1 million)

Q: What is the largest digit available in base 6?

A: 5 (digits in base B range from 0 to B minus 1)

Q: Convert the base 8 number 624 to decimal.

A: 6x64 + 2x8 + 4x1 = 384 + 16 + 4 = 404


Connections to Other Topics

This connects directly to Chapter 4 (Data Formats), where character codes like ASCII and Unicode are stored as binary numbers of specific bit widths. It also sets up Chapter 5 (signed integers, floating point), where the same positional system is used with additional rules for representing negative numbers and fractions. Understanding weights and ranges is essential for memory addressing covered later in the course.


Related Terms / Search Tags: number base, radix, binary number system, base 2, base 8, base 10, base 16, positional number system, binary digit, hexadecimal notation, octal notation, bit grouping, byte, halfword, word, doubleword, range formula, digit weight, IFT 510 Quiz 3, Foundations of Computer Science Purdue