Number Systems
Number systems are used to represent numbers in the computer system architecture.
1 Terminologies
Number bases
- A number base is the combination of digits that a counting system uses to represent numbers.
Representing number bases
- We represent a number and its base by denoting the base as a subscript of the number.
- Example: Decimal representation of 2 is 210
Bits
- A bit(short for binary digit) is the smallest unit of data in a computer.
- The maximum number of values that can be represented by $n$ number of bits is $2^n$.
Why do computers use binary numbers?
- In binary, there are only two states: 0 or 1. Likewise, a single switch also has two states, namely on or off.
- Numbers can be encoded in binary format and stored using switches. Switches can be grouped together to store large numbers. These combinations of numbers can be used to represent things like symbols and colours.
ASCII
- Short for American Standard Code for Information Interchange
- A standard data encoding format for electronic communications between computers.
- Consists of numbers letters, punctuation marks, etc.
Significance of bits
- In binary numbers, the right most digit is called the least significant bit(LSB) and the leftmost digit is called the most significant bit(MSB).

2 Number Systems
2.1 Decimal Number System (Base 10)
The decimal number system is a base 10 number sytem with digits from 0 to 9. It is also a positional value sytem, which means that the value of digits is dependent on its position.

2.2 Binary Number System (Base 2)
The binary number system is also a positional value system, where each digit has a value expressed in powers of 2.

2.3 Decimal-Binary Conversion
2.3.1 Binary to Decimal
The decimal equivalent of any binary number is the sum of product of each digit with its positional value.

2.3.2 Decimal to Binary
We can convert decimal numbers into binary numbers by performing short division by 2 successively as shown:
- Take decimal number as the dividend.
- Divide it by 2 (as we want to convert it to binary) and round down to the nearest integer.
- Store the remainder in an array.
- Repeat steps 1 to 4 until the divident becomes 0.
- Write the array in reverse order.
Example: Converting 11210 to binary
Division Remainder 112 / 2 = 56 0 56 / 2 = 28 0 28 / 2 = 14 0 14 / 2 = 7 0 7 / 2 = 3 1 3 / 2 = 1 1 1 / 2 = 0 1 Write the remainder from bottom to up, which gives us 1110000. Hence, 11210 = 11100002.
2.4 Hexadecimal Number System (Base 16)
The hexadecimal system consists of the digits 0-9 and the letters A-F, where A represents 10, B represents 11, C represents 12 and so on. It is a positional value system where each digit is expressed in powers of 16.
2.4.1 Decimal-Hexadecimal Conversion
Examples:
1. Hexadecimal to decimal
The decimal equivalent of any hexadecimal number is the sum of product of each digit with its positional value.
2. Decimal to hexdecimal
Similar to decimal to binary conversions, we can use the succesive division method for decimal to hexadecimal conversions.
2.4.2 Binary-Hexadecimal Conversion
With conversions between binary and hexadecimal numbers, we will use the grouping method instead.
Examples:
1. Hexadecimal to binary
Each hexadecimal digit corresponds to 4 binary digits. We simply convert each individual hexadecimal value into its binary equivalent and then concatenate them together.
2. Binary to hexadecimal
For binary to hexadecimal, we do the opposite. We divide the binary number into groups of four digits, then convert each individual group into its corresponding hexadecimal value, and concatenate them together.
In this example, 1 is actually equivalent to 0001, which is why the grouping method works despite the fact that it’s a single digit.
References:



