Lesson 01: Digital Systems and Number Systems
1.2 Number and Number Systems
Number and Number Systems
A number system is a way to represent numbers.
Ten is an important number for us humans. Most of us have ten fingers and toes, and we certainly prefer to have all ten of each. Because the fingers are convenient for counting, people started using their fingers to count from 1 to 10. It is a decimal system, which is also called a base-10 number system. Even if a lot of number systems are in base 10, humans did not always count in base 10 and we are still using other numeral bases. Here are a few examples:
- The base-60 counting system is still used today with this "60 seconds in a minute; 60 minutes in an hour".
- The base-24 system is used for counting 24 hours to be one day.
- The base-12 system is used for counting one dozen.
Figure 1: Ten fingers on two hands, the possible starting point of the decimal counting
If humans had 6 fingers on their hands, would we be using the Senary system (also known as heximal or Seximal) of numbers?
In a digital system, each digit (bit, wire) has only two possible values: 0 or 1. It is called a Binary, or base-2 number system. If there is a long binary number, for example (101110100101)binary, it is not suitable for humans to remember, and it is easily confused. One good way to reduce the length of the binary numbers is by grouping consecutive binary digits into groups of another number system. Therefore, we are using Octal (a base-8 number system) and Hexadecimal (a base-16 number system) to represent a binary number in the digital system.
In mathematics, a 「base」 or a 「radix」 is the number of different digits or combination of digits and letters that a system of counting uses to represent numbers. ~Wiki~
Decimal
Decimal
Characteristics of the decimal number system are as follows:
- Also called denary
- Base-10
- Uses decimal digits: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
- Positional System — position gives power to the base
- Example:
3845.2 = (3 x 103) + (8 x 102) + (4 x 101) + (5 x 100) + (2 x 10-1) - Positions: …5 4 3 2 1 0 . -1 -2 -3 …
The base-10 system is a Positional Number System. it means each digit has s different value according to its position. For example: 255 is (2 x 100) + (5 x 10) + (5 x 1). There are a lot of other numeral systems which does not work that way. One of the most famous is Roman numerals, which is not really a positional system. In the Roman number system, The X stands for 10, the V stands for 5, and the I is a one. Twenty-seven in Roman numerals is XXVII ; it is 10 + 10 + 5 + 1 + 1 = 27 in decimal.
Binary
Binary
In a computer, all the information is stored using digital signals that translate to binary numbers. A single bit can represent two possible states: on (1) or off (0).
Characteristics of the binary number system are as follows:
- Base-2
- Digits: {0, 1}
- Binary Digits are called bits
- Positional system
- Example:
1101.12 = (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) + (1 x 2-1)
Octal
Octal
Characteristics of the binary number system are as follows:
- Base-8
- Digits: {0, 1, 2, 3, 4, 5, 6, 7}
- A group of 3 binary digits can be used to represent each octal digit
- Positional system
- Example:
3578 = (3 x 82) + (5 x 81) + (7 x 80)
Hexadecimal
Hexadecimal
Characteristics of the hexadecimal number system are as follows:
- Base-16
- Digits: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
- Groups of 4 bits represent each base 16 digit
- Positional system
- Example:
1F416 = (1 x 162) + (F x 161) + (4 x 160)
BCD
BCD
BCD (Binary Coded Decimal) is a decimal number system, where each decimal digit is represented by a 4-bit binary number.
Do not get confused, BCD is not the same as hexadecimal. The hexadecimal also uses a 4-bit binary to represent one hex digit. Each hex digit is valid up to (F)16 representing binary (1111)2. But the one decimal digit is only up to 9 binary (1001)2. This means, that the 4-bit binary can represent 16 numbers (24), in the BCD number system, the six binary codes from (1010)2 (decimal 10) to (1111)2 (decimal 15) are not used.
The main advantage of BCD is that it allows easy conversion between decimal and binary forms. However, the disadvantage is that the BCD code is wasteful as the states between (1010)2 and (1111)2 are not used.
For example, give the BCD representation for the decimal numbers 90 and 873.
The BCD representation of the number 90 is written as follows:
(90)10 = (1001 0000)BCD
For the number 873:
(873)10 = (1000 0111 0011)BCD
Gray Code
Gray Code
A Gray Code is an encoding of numbers so that adjacent numbers have one single digit differing by 1. This coding technique was invented by Frank Gray, thus it is named so. The term Gray code is often used to refer to a "reflected" code, or more specifically still, the binary reflected Gray code.
Gray Code is a non-weighted code, as it does not ascribe a specific weight to each bit position. It is not used for arithmetic calculations.
Gray code is used in Karnaugh maps and in the design of logic circuits. They also find application in rotary encoders, where the predisposition to errors increases with the number of bits that change logical states between two consecutive positions.
Gray Code Advantage
- It can be used to minimize a logic circuit.
- It minimizes error while converting analog to digital signals.
Gray Code Disadvantage
- It is not suitable for arithmetic operations.
- It is limited to a few practical applications.
ASCII Code
ASCII Code
ASCII code (American Standard Code for Information Interchange) has seven bits allowing for the representation of 27 = 128 symbols.
Table 1: ASCII Table
Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0x00 | NULL | null | 32 | 0x20 | SP | 64 | 0x40 | @ | 96 | 0x60 | ` |
1 | 0x01 | SOH | Start of heading | 33 | 0x21 | ! | 65 | 0x41 | A | 97 | 0x61 | a |
2 | 0x02 | STX | Start of text | 34 | 0x22 | " | 66 | 0x42 | B | 98 | 0x62 | b |
3 | 0x03 | ETX | End of text | 35 | 0x23 | # | 67 | 0x43 | C | 99 | 0x63 | c |
4 | 0x04 | EOT | End of transmission | 36 | 0x24 | $ | 68 | 0x44 | D | 100 | 0x64 | d |
5 | 0x05 | ENQ | Enquiry | 37 | 0x25 | % | 69 | 0x45 | E | 101 | 0x65 | e |
6 | 0x06 | ACK | Acknowledge | 38 | 0x26 | & | 70 | 0x46 | F | 102 | 0x66 | f |
7 | 0x07 | BELL | Bell | 39 | 0x27 | ' | 71 | 0x47 | G | 103 | 0x67 | g |
8 | 0x08 | BS | Backspace | 40 | 0x28 | ( | 72 | 0x48 | H | 104 | 0x68 | h |
9 | 0x09 | TAB | Horizontal tab | 41 | 0x29 | ) | 73 | 0x49 | I | 105 | 0x69 | i |
10 | 0x0A | LF | New line | 42 | 0x2A | * | 74 | 0x4A | J | 106 | 0x6A | j |
11 | 0x0B | VT | Vertical tab | 43 | 0x2B | + | 75 | 0x4B | K | 107 | 0x6B | k |
12 | 0x0C | FF | Form Feed | 44 | 0x2C | , | 76 | 0x4C | L | 108 | 0x6C | l |
13 | 0x0D | CR | Carriage return | 45 | 0x2D | - | 77 | 0x4D | M | 109 | 0x6D | m |
14 | 0x0E | SO | Shift out | 46 | 0x2E | . | 78 | 0x4E | N | 110 | 0x6E | n |
15 | 0x0F | SI | Shift in | 47 | 0x2F | / | 79 | 0x4F | O | 111 | 0x6F | o |
16 | 0x10 | DLE | Data link escape | 48 | 0x30 | 0 | 80 | 0x50 | P | 112 | 0x70 | p |
17 | 0x11 | DC1 | Device control 1 | 49 | 0x31 | 1 | 81 | 0x51 | Q | 113 | 0x71 | q |
18 | 0x12 | DC2 | Device control 2 | 50 | 0x32 | 2 | 82 | 0x52 | R | 114 | 0x72 | r |
19 | 0x13 | DC3 | Device control 3 | 51 | 0x33 | 3 | 83 | 0x53 | S | 115 | 0x73 | s |
20 | 0x14 | DC4 | Device control 4 | 52 | 0x34 | 4 | 84 | 0x54 | T | 116 | 0x74 | t |
21 | 0x15 | NAK | Negative ack | 53 | 0x35 | 5 | 85 | 0x55 | U | 117 | 0x75 | u |
22 | 0x16 | SYN | Synchronous idle | 54 | 0x36 | 6 | 86 | 0x56 | V | 118 | 0x76 | v |
23 | 0x17 | ETB | End transmission block | 55 | 0x37 | 7 | 87 | 0x57 | W | 119 | 0x77 | w |
24 | 0x18 | CAN | Cancel | 56 | 0x38 | 8 | 88 | 0x58 | X | 120 | 0x78 | x |
25 | 0x19 | EM | End of medium | 57 | 0x39 | 9 | 89 | 0x59 | Y | 121 | 0x79 | y |
26 | 0x1A | SUB | Substitute | 58 | 0x3A | : | 90 | 0x5A | Z | 122 | 0x7A | z |
27 | 0x1B | ESC | Escape | 59 | 0x3B | ; | 91 | 0x5B | [ | 123 | 0x7B | { |
28 | 0x1C | FS | File separator | 60 | 0x3C | < | 92 | 0x5C | \ | 124 | 0x7C | | |
29 | 0x1D | GS | Group separator | 61 | 0x3D | = | 93 | 0x5D | ] | 125 | 0x7D | } |
30 | 0x1E | RS | Record separator | 62 | 0x3E | > | 94 | 0x5E | ^ | 126 | 0x7E | ~ |
31 | 0x1F | US | Unit separator | 63 | 0x3F | ? | 95 | 0x5F | _ | 127 | 0x7F | DEL |
Decimal | Binary | Octal | Hexadecimal | BCD | Gray Code |
0 | 0 | 0 | 0 | 0000 | 0000 |
1 | 1 | 1 | 1 | 0001 | 0001 |
2 | 10 | 2 | 2 | 0010 | 0011 |
3 | 11 | 3 | 3 | 0011 | 0010 |
4 | 100 | 4 | 4 | 0100 | 0110 |
5 | 101 | 5 | 5 | 0101 | 0111 |
6 | 110 | 6 | 6 | 0110 | 0101 |
7 | 111 | 7 | 7 | 0111 | 0100 |
8 | 1000 | 10 | 8 | 1000 | 1100 |
9 | 1001 | 11 | 9 | 1001 | 1101 |
10 | 1010 | 12 | A | 0001 0000 | 1111 |
11 | 1011 | 13 | B | 0001 0001 | 1110 |
12 | 1100 | 14 | C | 0001 0010 | 1010 |
13 | 1101 | 15 | D | 0001 0011 | 1011 |
14 | 1110 | 16 | E | 0001 0100 | 1001 |
15 | 1111 | 17 | F | 0001 0101 | 1000 |
16 | 1 0000 | 20 | 10 | 0001 0110 | 1 1000 |
Conversions between Different Number Systems
Humans want to see and enter numbers in decimals, but computers must store and compute with bits. Therefore, we need to know how to convert a number into different number systems.
- Base-r Numbers to Decimal
- Decimals to Base-r Number
- Binary ↔ Octal
- Binary ↔ Hex
- Octal ↔ Hex
- Binary ↔ BCD Code
- Binary ↔ Gray Code
- Base-r Numbers to Decimal
- Decimals to Base-r Number
- Binary ↔ Octal
- Binary ↔ Hex
- Octal ↔ Hex
- Binary ↔ BCD Code
- Binary ↔ Gray Code
Base-r Numbers to Decimal
To convert any base-r number to decimal:
- Expand base-r number using the positional scheme
- Perform computation using decimal arithmetic
Base-r system to decimal system:
- Determine the positional value of each digit (this depends on the position of the digit and the base of the number system)
- Multiply the obtained positional values (in step 1) by the digits in the corresponding positions.
- Sum the products calculated in Step 2. The total is the equivalent value in decimal.
Ex1: Binary to Decimal
Convert (1101.01)2 to decimal.
23 | 22 | 21 | 20 | 2-1 | 2-2 | |||
Position | 3 | 2 | 1 | 0 | -1 | -2 | ||
(1101.01)2 | = | 1 | 1 | 0 | 1 | . | 0 | 1 |
(1101.01)2 = (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) + (0 x 2-1) + (1 x 2-2) = (13.25)10
Ex2: Octal to Decimal
Convert (432.2)8 to decimal.
82 | 81 | 80 | 8-1 | |||
Position | 2 | 1 | 0 | -1 | ||
(432.2)8 | = | 4 | 3 | 2 | . | 2 |
(432.2)8 = (4 x 82) + (3 x 81) + (2 x 80) + (2 x 8-1) = (282.25)10
Ex3: Hexadecimal to Decimal
Convert (B65F)16 to decimal.
163 | 162 | 161 | 160 | ||
Position | 3 | 2 | 1 | 0 | |
(B65F)16 | = | B | 6 | 5 | F |
(B65F)16 = (11 x 163) + (6 x 162) + (5 x 161) + (15 x 160) = (46,687)10
Decimals to Base-r Number
Use Radix Divide Method
The equation for decimal to base-r number:
Integral Part
- Divide (integral part) by the base- r number:
- Take the remainder as a coefficient
- Take the quotient and repeat the division, until the quotient is equal to zero
Fractional Part
- Multiply the number by the base- r number
- Take the integer (either 0 or 1) as a coefficient
- Take the resultant fraction and repeat the multiplication
Binary ↔ Octal
- 8 = 23
- Each group of 3 digits in binary represents an Octal digit
Binary to Octal Conversion
- Divide the binary digits into groups of 3 (starting from position 0)
- Convert each group of 3 binary digits to one octal digit.
Example: (10110.01)2 to Octal
Octal to Binary Conversion
- Convert each octal digit to a 3-digit binary number (the octal digits may be treated as decimals for this conversion).
- Combine all the resulting binary groups (of 3 digits each) into a single binary number.
Example: (25)8 to Binary
Octal | Binary |
0 | 000 |
1 | 001 |
2 | 010 |
3 | 011 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
Binary ↔ Hex
- 16 = 24
- Each group of 4 binary bits represents a Hexadecimal digit
Binary to Hexadecimal
- Divide the binary digits into groups of 4 (starting from position 0)
- Convert each group of 4 binary digits to one hexadecimal symbol.
Example: (11010.01)2 to Hex
Hexadecimal to Binary
- Convert each hexadecimal digit to a 4-digit binary number (the hexadecimal digits may be treated as decimal for this conversion)
- Combine all the resulting binary group (of 4 digits each) into a single binary number
Example: (15)16 to Binary
Hex | Binary | Decimal |
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
A | 1010 | 10 |
B | 1011 | 11 |
C | 1100 | 12 |
D | 1101 | 13 |
E | 1110 | 14 |
F | 1111 | 15 |
Octal ↔ Hex
Convert to Binary as an intermediate step
Example: (26.2)8 to Hex
Works both ways (Octal to Hex & Hex to Octal)
Binary ↔ BCD Code
Binary-to-BCD Conversion
To convert binary to BCD, we will first convert the binary number to decimal and then the decimal number to BCD number. Similarly, to convert BCD to binary, we will first convert the BCD to decimal, and then decimal to equivalent binary.
Binary ↔ Gray Code
Binary-to-Gray Code Conversion
Binary to Gray Code Conversion
The conversion process from binary code to gray code involves the following steps:
- MSB (most significant bit) or the leftmost bit of the given binary is the same as MSB of the gray number.
- To get the next bit of gray code, add MSB with the next bit of binary number (move from left to right). Write the sum and discard the carry.
- Repeat step 2 for all the bits in the sequence till LSB.

Gray to Binary Code Conversion
The steps given below are required to be followed in order to convert a given gray value into its binary equivalent:
- MSB does not change. So, write the leftmost bit of gray code as the MSB of binary code.
- Now, add the recently achieved binary digit with the next adjacent gray code bit. The sum must be written as the next bit of binary equivalent, while the carry must be discarded.
- The above-discussed step must be followed for all the bits present in the sequence.

The 1-bit adder can be represented as xor logic.
Figure 2: Gray Code Conversion using XOR logic
Basically, the number systems can be cataloged into two groups: decimal and binary systems.
Figure 1: Number of Systems
We can easily convert numbers between decimal and binary systems. If you need to convert a BCD number to another system, such as octal, the best solution is to convert the BCD number to decimal first, then convert it to binary, and finally to octal number.
Common Powers
Most of the common powers of base-10 and base-2 number systems are shown as follows:
Power | Preface | Symbol | Value |
10-12 | pico | p | 0.000000000001 |
10-9 | nano | n | 0.000000001 |
10-6 | micro | µ | 0.000001 |
10-3 | milli | m | 0.001 |
103 | kilo | K | 1,000 |
106 | mega | M | 1,000,000 |
109 | giga | G | 1,000,000,000 |
1012 | tera | T | 1,000,000,000,000 |
Power | Preface | Symbol | Value |
210 | kilo | K | 1,024 |
220 | mega | M | 1,048,576 |
230 | giga | G | 1,073,741,824 |
240 | tera | T | 1,099,511,627,776 |
250 | peta | P | |
260 | exa | E | |
270 | zetta | Z | |
280 | yotta | Y |
Questions
Q1: Convert to Binary
Convert the following numbers to binary:
a) (37)10 | b) (15)10 | c) (187)10 | d) (2014)10 | e) (2016)10 |
f) (2.75)10 | g) (25.25)10 | h) (243.3125)10 | i) (0.0625)10 | j) (62)8 |
k) (277)8 | l) (12.6)8 | m) (476.35)8 | n) (96)16 | o) (37FD)16 |
p) (7FF)16 | q) (1A6)16 | r) (2C0)16 | s) (1F.C)16 | t) (9.F)16 |
u) (A7.EC)16 |
Q2: Convert to Decimal
Convert the following numbers to decimals:
a) (1 0110)2 | b) (1 0001)2 | c) (1000 1101)2 | d) (1001 0000 1001)2 | e) (11 1101 0111)2 |
f) (1011.101)2 | g) (100 1101 1001.1011)2 | h) (30)8 | i) (115)8 | j) (55.4)8 |
k) (270.54)8 | l) (356)16 | m) (2AF)16 | n) (2C1)16 | o) (10FF)16 |
p) (1FCFA)16 | q) (DADA.C)16 | r) (F.4)16 | s) (EBA.C)16 | t) (420.32)5 |
Q3: Convert to Hexadecimal
Convert the following numbers to hexadecimals:
a) (320)10 | b) (6,861)10 | c) (65,535)10 | d) (100)8 |
e) (62.4)8 | f) (500.25)8 | g) (1000 1101)2 | h) (100_1000_1101_0001_1110)2 |
i) (1 0000.1)2 | j) (1000 000.0000 111)2 | k) (10 0011 1001.01)2 |
Q4: BCD to Decimal
Convert the following BCD numbers to decimals:
a) (0001 1000 0100)BCD | b) (0100 1001 0010)BCD | c) (1001 0111 0101 0010)BCD | d) (0111 0111 0111 0101)BCD |
Q5: Convert to Gray Code
Convert the following binary numbers to Gray code:
a) (1 1011)2 | b) (10 1101)2 | c) (1100 0110)2 |
1.3 Negative Number in Binary
An unsigned binary number has no arithmetic sign. Unsigned binary numbers are, therefore, always positive. Typical examples are your age or a memory address which are always positive numbers. An 8-bit unsigned binary integer represents all numbers from 0016 through FF16 (010 through 25510).
Signed binary numbers, on the other hand, include both positive and negative numbers. the techniques used to represent the signed integers are:
- Sign-magnitude approach
- One's complement approach
- Two's complement approach