Decimal Numbers
Uses a base of 10, implying 2 important properties for the interpretation and representation of decimal values
- Any individual digit in a base 10 number stores one of 10 unique values (0-9)
- Storing a value , the value must carry to an additional digit to the left.
- The position of each digit in the number determines how important that digit is to the overall value of the number
- Each successive digit (to the left) contributes a factor ten more than the next

- The in the “ones” place contributes 5 ().
- The 2 in the “tens” place contributes 20 ().
- The 4 in the “hundreds” place contributes 400 ().
- The 8 in the “thousands” place contributes 8000 ()
- Each successive digit (to the left) contributes a factor ten more than the next
- Which can express the value as
NOTE
This pattern of increasing exponents applied to a base of is the reason why it’s called a base 10 number system Assigning position numbers to digits from right to left starting from → each digit contributes to the overall value
The overall value of any -digit decimal number can be expressed as:
Unsigned Binary Numbers
Uses a base of 2 instead of decimal’s 10. And we can analyze binary numbers the same way as decimal numbers
- Any Individual bit in a base 2 number stores up to 2 unique values (
0or1)- To store a value larger than
1, the binary encoding must carry to an additional bit to the left - Counting in binary follows the same pattern as decimal → enumerate the values and adding digits (bits)
- To store a value larger than
| Binary Value | Decimal Value |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 10 | 2 |
| 11 | 3 |
| 100 | 4 |
| 101 | 5 |
| 110 | 6 |
| 111 | 7 |
| … | … |
- The position of each bit in the number determines how important that bit is to the numerical value of the number
- Very similar to decimal → replace 10 at the base of each exponent with a 2
Hexadecimal
Uses a base 16, which is used mainly to convert binary representation. Also due to the base itself is a power of two (), it’s easy to map hexadecimal to binary and vice versa. As similar to the decimal and binary, hexadecimal can be interpreted in a similar way
- Any digit in a base 16 number stores one of 16 unique values
- Digits 0-9 represents the values 0-9
- Characters A-F represents the values 10-15 respectively
- To store a value larger than 15, the number must carry to an additional digit to the left
- The position of each digit in the number determines how important that digit is to the numerical value of the number
WARNING
Hexadecimal Misconception
Memory Addresses are most common to be represented in hexadecimal output. But memory address are still stored using binary in the hardware, just like other data
IMPORTANT
Distinguishing Number Bases
One potential problem is a lack of clarity for how to interpret number
Example:
Consider the value . It is not immediately obvious whether to interpret number as decimal, a binary, or a hexadecimalTo Indicate which numbering systems we use to represent such values, we attach a prefix to all non-decimal numbers:
- 0b: The prefix for binary number> - 0x: The prefix for hexadecimal numbers
Storage Limitations
A programmer must choose how many bits to dedicate to a variable prior to storing it
- Before storing a value, a program must allocate storage space for it.
- In C, declaring a variable tells the compiler how much memory it needs based on its type
- Hardware storage devices have finite capacity.
- A storage locations inside the CPU that are used as temporary “scratch space” (registers) are more constrained.
- A CPU uses registers that are limited to its word size (
32or64bits depending on CPU architecture)
- Programs often move data from one storage device to another
- As values get larger, storage devices need more physical wires to communicate signals between each other for memory locations
- Expanding storage increases complexity of the hardware → leaves less physical space for other components
Representing Data
Due to this limitation, the number of bits used to store an integer dictates the range of its representable values

- Left Picture: Represents an infinite unsigned number line
- Right Picture: Represents a finite unsigned number line
- “wraps around” at either endpoint, which can cause **overflow
Since there is a limit to the amount of bits a variable can possess → what is the largest positive value that bits can store?
For any given integer value , there are exactly unique bit patterns. However one of such unique bit pattern represents the value 0. Therefore that leaves the maximum positive integer value of → positive values ranges from