0% found this document useful (0 votes)
4 views

chapter2_numberSystem

Chapter 2 discusses various numerical systems including decimal, binary, hexadecimal, and octal, highlighting their significance in computing and everyday use. It explains the conversion processes between these systems, emphasizing the importance of understanding these conversions for effective communication between humans and computers. The chapter also includes examples and exercises to reinforce the concepts of number representation and conversion.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

chapter2_numberSystem

Chapter 2 discusses various numerical systems including decimal, binary, hexadecimal, and octal, highlighting their significance in computing and everyday use. It explains the conversion processes between these systems, emphasizing the importance of understanding these conversions for effective communication between humans and computers. The chapter also includes examples and exercises to reinforce the concepts of number representation and conversion.

Uploaded by

eliasaraya142
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Chapter 2

Number of Systems and Codes


Numerical system is a representative way to display digits, symbols, or letters. Binary number is the
fundamental system use in computers and digital electronics because computers store information as 0
and 1, or “bits”, which is a short word for binary digit. On the other hand, outside the computer world, the
universal number of system used to represent quantities is the decimal system. Decimal system is the
number system used in every day to represent quantities from the beginning of many ancient cultures
where they calculated with numerals based on ten, as the human hands have 10 digits.

In this chapter, students will learn the different number of system use between the world of computers and
humans, and how to make the conversion between systems in order for the two different world to
understand and communicate.

2.1. Decimal system


Decimal system is the quantity system uses by humans. The system started from ancient cultures when people used
their 10 hands’ fingers to count. Thus, a decimal numbering system has 10 different digits to represent the quantities
of the systems. As the number zero “0” is considered to be the starts points of the counting system, the digits for
the decimal system are 0,1,2,3,4,5,6,7,8, and 9.
For instant, when digits are placed in a different position
from right to left from the decimal point, the digits have a
value ten times larger than the previous digits. Thus, a
decimal systems is a base of 10 system, and digits have an
increasing weight position of ten from the right to the left.
Also, the first digit from the right side (rightmost) is the
Least Significant Digit, LSD, since it is the digit at the first
counting process, and it has a weighting factor of 100. On
the other hand, the leftmost digit is the Most Significant
Digit, MSD, since it is the last digit to count, and it has the
Image credits: Creator: pepifoto, Credit: Getty Images/iStockphoto greatest weighting factor.

Example 2.1. – Decimal number


Given a 3-digit decimal number 571, the lest significant digit is “1”, which has a weight position factor of 100, and
the most significant digit is 5, which has a weigh position factor of 10 2. When the digit values are added up, the
total is the decimal value, and a subscript is added next to LSD to identify the system that the digits represent. In

1|P a g e
this case 57110. Usually a subscript is not necessary for a decimal number but subscripts are recommended when
numerical systems since digit might be repeated in different number of system, and a way to identify the different
system is by subscript of their respective system base.

Increasing power of 10

5 7 1. Decimal Point

1  100 = 1
7  101 = 70
5  102 = 500

Total decimal quantity = 500 + 70 + 1 = 57110

Exercise 2.1. – Decimal number

For the given decimal numbers, identify the LSD, MSD, and each digit weight position factor:
a. 3,708
b. 10,526
c. 490

2.2. Binary number

Digital devices use a different method called binary system to identify and represent digits. Binary system uses two
digits, which is 0 and 1, to represent two distinct voltage level. The digit “0” is used to represent a voltage of or
approximately 0 V, and the digit “1” is used to represent a voltage of or approximately 5 V.
Also, each binary digit is called a “bit”, the most-right bit is known as the least significant bit, and the most-left bit
is known as the most significant bit. Also, a subscript of 2 is added to the LSB to identify the number as a binary
number or string.
Hence, the digits for the binary system is 0 and 1, and it is a base of 2 system.

2|P a g e
Example 2.2. – Binary number
For a 4-bit binary number 11002, the MSB, LSB, and the weight position factor is identified as:

1 1 0 02 Base of 2 (binary system)

0  20 (LSB)
0  21
1  22
1  23 (MSB)

Exercises 2.2 – binary number

For the given binary numbers, identify the LSB, MSB, and each digit weight position factor:
a. 1011002
b. 111012
c. 1010102

2.3. Hexadecimal system

In digital, the term code refers to the sequence of symbols or characters, and a binary code is no more than
a sequence of 1s and 0s. Since binary code are extremely long, one way to simplify a binary code is by
grouping into a group of 4-bit or 3-bit. One group of 4-bit is called a nibbles and one group of 8-bit (2
nibbles) is called bytes. A system to group a binary code into a group of 4-bit is called the hexadecimal
number of system. It is a base 16 system because it has 16 digits, 24 = 16. One group of 4-bit represents
a single hexadecimal digit. The representation of each hexadecimal digit is by numbers from 0 to 9 and
by letter in the alphabetic order from A to F to represent the values of 10, 11, 12, 13, 14, and 15,
respectively.
Since hexadecimal uses 4-bit grouping, then instructions or data used in the computer systems is in two
(1 byte), four (2-byte), or eight (3-byte) hexadecimal code, which is must easier and faster to read than a
long string of binary digits.

3|P a g e
Example 2.3. – Hexadecimal number

1000111011002 (Binary code)


1000 1110 11002 (Hexadecimal system grouping)

MSB LSB
1000 1110 11002 Grouping of 4-bit stars from the LSB to the MSB
direction. One group of 4-bit is equivalent to one
Group-3 Group-2 Group-1
hexadecimal digit

One example of hexadecimal application is the hexadecimal color palette (a hex triplet) of a graphic design
application, where it uses two hexadecimal digit to represent one level of color variation among the color
of Red, Green, and Blue (RGB).

2.4. Octal system

Like the hexadecimal number system, the octal number system provides a convenient way to express
binary number and codes. One octal digit is a decimal representation of a group of 3-bit. Therefore, the
octal number system is a base of 8 (23 = 8) system composed of eight digits: 0,1,2,3,4,5,6,7.

Example 2.4. – Octal number

1000111011002 (Binary code)


100 011 101 1002 (Octal system grouping)

4|P a g e
MSB LSB Grouping of 3-bit stars from the LSB
to the MSB direction. One group of 3-
100 011 101 1002 bit is equivalent to one octal digit

Group-4 Group-3 Group-2 Group-1

History has showed that some ancient culture such as the Native American Yuki and the Mexican Pamean
cultures used octal system because the count using the spaces between their fingers instead of the fingers
themselves.
Octal or base eight system is used in older computer as
their base system especially in system that employed 12-
bit, 24-bit, or 36-bit words. Since each octal digit
represents three binary digit, computer with octal base
system has their word size divisible by three-bit.
However, most modern computing platforms use 16-bit,
32-bit, or 64-bit words, which the word size is divisible
by eight-bit, a byte.

2.5. Conversion between systems

The original computers were used primarily as calculators, but later they were used to manipulate other
forms of information, such as words, symbols, and pictures. In each case, engineers and programmers sat
down and decided how they were going to represent a new type of information in binary form. Although
it is pretty complicated to do so, sounds and pictures can also be converted into binary numbers, too. They
have to be divided up into small elements (“samples” in audio or “pixels” for pictures), and then every
element has to be assigned a number. The result is a huge array of binary numbers, and the volume of all
this data is one reason why image files on a computer are so large, and why it is relatively slow to view
video or download audio over an internet connection.

One of the practices by which it is important to understand the conversion between numerical systems is
the representation of a binary code in words. For example, with 8 bit binary, 0101 11002, many logic and
protocol analyzers and Binary Editors will show these sequences with a hex value as 5CHex. A familiar
binary code sequence 010 00112, represents as 23Hex also having the ASCII representation the symbol
hash #

5|P a g e
2.5.1. Conversion from binary, hexadecimal, or octal system to decimal system

The conversion from binary, hexadecimal, or octal system to decimal number is done by using the
weight position values and the base of the given number. The basic steps for the conversion is:

1. Identify and label the LSD and the MSD of the given number

2. Identity the appropriate base weigh position factor for each given digit
from the LSD to the MSD

3. Multiply each given digit with their respective base weight

4. Sum all the product from step 3.

5. Label the result in step 4 with subscript 10 to identify that the number
is the converted decimal number.

Example 2.5. – convert from binary to decimal


Given 1001012, what would be its decimal value?
Step 1: Identify and label the LSD and the MSD of the given number

1 0 0 1 0 12
(LSB)
(MSB)

Step 2: Identity the appropriate base weigh position factor for each given digit from the LSD to the MSD

1 0 0 1 0 12
20 (LSB)
21
22
23
24
25 (MSB)

6|P a g e
Step 3: Multiply each given digit with their respective base from step 2.

1 0 0 1 0 12
120 = 1(LSB)
021 = 0
122 = 4
023 = 0
024 = 0
125 = 32(MSB)

Step 4. Sum all the product from step 3.

32+0+0+4+0+1 = 37
Step 5. Label the result in step 4 with subscript 10 to identify that the number is the converted decimal
number.

Answer = 3710

Example 2.6. – convert from hexadecimal to decimal


Given C27F16, what would be its decimal value?
Step 1: Identify and label the LSD and the MSD of the given number

C 2 7 F16
(LSB)
(MSB)

Step 2: Identity the appropriate base weigh position factor for each given digit from the LSD to the MSD

C 2 7 F16
160 (LSB)
161
162
163 (MSB)

7|P a g e
Step 3: Multiply each given digit with their respective base from step 2.

C 2 7 F16
F = 15160 = 15 (LSB)
7161 = 112
2162 = 512
C = 12163 = 49152 (MSB)

Step 4. Sum all the product from step 3.


49152+512+112+15 = 49791

Step 5. Label the result in step 4 with subscript 10 to identify that the number is the converted decimal
number.

4979110

Example 2.7. – convert from octal to decimal


Given 358, what would be its decimal value?
Step 1: Identify and label the LSD and the MSD of the given number
3 58
(LSB)
(MSB)

Step 2: Identity the appropriate base weigh position factor for each given digit from the LSD to the MSD
3 58
80 (LSB)
81 (MSB)
Step 3: Multiply each given digit with their respective base from step 2.
3 58
580 = 5(LSB)
381 = 24(MSB)

Step 4. Sum all the product from step 3.


24+5=29

8|P a g e
Step 5. Label the result in step 4 with subscript 10 to identify that the number is the converted decimal
number.

2910

Exercise 2.3 – conversion to decimal system


Convert the following numbers into a decimal number
a. 10010102
b. A0716
c. 7218

2.5.2. Conversion from decimal system to binary, hexadecimal, or octal system


Recalling the part of a division

The conversion decimal system to binary, hexadecimal, or octal system is done by using repeating
division with the base value of the given number, and the remainder of each division is the converted
number. The basic steps for the conversion is:

1. Divide the given decimal number (divident) with the base value of the system (divisor)
that we are converting to.

2. The remainder of step 1 is the converted digit. The first remainder digit is the LSD

3. Take the quotient from the previous division and divide it again with the base value of
the system (divisor) that we are converting to. The remainder is the next converted digit.

4. Repeat step 3 until the quotient of the division becomes zero "0". The last remainder
digit is the MSD

5. Write all the converted digit, which are all the remainders digit, from the LSD to the
MSD (from rightmost digit to the leftmost digit). Do not forget to include the base
subscript
9|P a g e
Example 2.8. – Conversion from decimal system to binary system
What is the binary code of 3710?
Step 1: Divide the given decimal number (dividend) with the base value of the system (divisor) that we
are converting to.
37 is the dividend, and 2 is the divisor since the conversion is to binary code, which is base of 2
37
2
Step 2: The remainder of step 1 is the converted digit. The first remainder digit is the LSB

37 1
= 18 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 1 (𝐿𝑆𝐵)
2 2
Step 3. Take the quotient from the previous division and divide it again with the base value of the
system (divisor) that we are converting to. The remainder is the next converted digit.
18
= 9.0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 0
2
Step 4. Repeat Step 3 until the quotient of the division becomes zero "0". The last remainder is the MSB
9 1
= 4 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 1
2 2

4
= 2.0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 0
2

2
= 1.0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 0
2

1 1
= 0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 1 … . 𝑄𝑢𝑜𝑡𝑖𝑒𝑛𝑡 = 0 → 𝑆𝑇𝑂𝑃 𝑑𝑖𝑣𝑖𝑠𝑖𝑜𝑛 (𝑀𝑆𝐵)
2 2

Step 5. Write all the converted digit, which are all the remainders digit, from the LSB to the MSB (from
rightmost digit to the leftmost digit). Do not forget to include the base subscript

1 0 0 1 0 12
(LSB)
(MSB)

10 | P a g e
Example 2.9. – Conversion from decimal system to hexadecimal system
What is the hexadecimal code of 21510?
Step 1: Divide the given decimal number (dividend) with the base value of the system (divisor) that we
are converting to.
215 is the dividend, and 16 is the divisor since the conversion is to hexadecimal code, which is base of
16
215
16
Step 2: The remainder of step 1 is the converted digit. The first remainder digit is the LSD
215 7
= 13 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 7 (𝐿𝑆𝐷)
16 16
Step 3. Take the quotient from the previous division and divide it again with the base value of the
system (divisor) that we are converting to. The remainder is the next converted digit.
Step 4. Repeat step 3 until the quotient of the division becomes zero "0". The last remainder is the MSD

13 13
=0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 13 … 𝑄𝑢𝑜𝑡𝑖𝑒𝑛𝑡 = 0 → 𝑆𝑇𝑂𝑃 𝑑𝑖𝑣𝑖𝑠𝑖𝑜𝑛 (𝑀𝑆𝐷)
16 16

13 is equivalent to D in hexadecimal

Step 5. Write all the converted digit, which are all the remainders digit, from the LSD to the MSD (from
rightmost digit to the leftmost digit). Do not forget to include the base subscript

D 716
(LSD)
(MSD)

11 | P a g e
Example 2.10. – Conversion from decimal system to octal system
What is the octal code of 968?
Step 1: Divide the given decimal number (dividend) with the base value of the system (divisor) that we
are converting to.
96 is the dividend, and 8 is the divisor since the conversion is to octal code, which is base of 8
96
8
Step 2: The remainder of step 1 is the converted digit. The first remainder digit is the LSD
96
= 12.0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 0 (𝐿𝑆𝐷)
8
Step 3. Take the quotient from the previous division and divide it again with the base value of the
system (divisor) that we are converting to. The remainder is the next converted digit.

12 4
= 1 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 4
8 8

Step 4. Repeat step 3 until the quotient of the division becomes zero "0". The last remainder is the MSD
1 1
= 0 → 𝑅𝑒𝑚𝑎𝑖𝑛𝑑𝑒𝑟 = 1 … . 𝑄𝑢𝑜𝑡𝑖𝑒𝑛𝑡 = 0 → 𝑆𝑇𝑂𝑃 𝑑𝑖𝑣𝑖𝑠𝑖𝑜𝑛 (𝑀𝑆𝐷)
8 8

Step 5. Write all the converted digit, which are all the remainders digit, from the LSD to the MSD (from
rightmost digit to the leftmost digit). Do not forget to include the base subscript

1 4 08
(LSD)
(MSD)

Exercise 2.4 – conversion from decimal to binary, hexadecimal, and octal system
a. What is the binary code of 7010? 1000110
b. What is the hexadecimal code of 52610? 20E
c. What is the octal code of 2788? 426

12 | P a g e
2.5.3. Conversion from binary to hexadecimal system
Converting a binary number to hexadecimal is a straightforward procedure. Simply break the binary code
into 4-bit groups from the LSB to the MSB order, and replaces each 4-bit group with the equivalent
hexadecimal symbol. One way to do the replacement is to convert the 4-bit group into its equivalent
decimal value and convert the decimal value into a hexadecimal digit.

Binary code Decimal equivalent Hexadecimal digit


0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F

1. Break the binary code into 4-bit groups from the LSB to the
MSB

2. If the last group does not have 4 bit in the group, fill the bit
place with “0” up to 4-bit

3. Convert each group of 4-bit into its decimal value

4. Convert each decimal value to its respective hexadecimal


digit

13 | P a g e
Example 2.11. – Conversion from binary to hexadecimal system
Convert the following binary code into a hexadecimal code 101110101001002
Step 1: Break the binary code into 4-bit groups from the LSB to the MSB

10 1110 1010 01002


(LSB)
(MSB)
Step 2: If the last group does not have 4 bit in the group, fill the bit place with “0” up to 4-bit

0010 1110 1010 01002


(LSB)
(MSB)
Step 3: convert each group of 4-bit into its decimal value

0010 1110 1010 01002


2 14 10 3

Step 4: convert each decimal value to its respective hexadecimal digit

0010 1110 1010 01002


2 14=E 10=A 3

Answer: 2EA316

Exercise 2.5 – conversion from binary system to hexadecimal system


Convert the following binary code into hexadecimal code
a. 10111012
b. 111100010012
c. 1010101012

14 | P a g e
2.5.4. Conversion from hexadecimal system to binary system
Conversion from hexadecimal number to binary number is a straightforward method. It replaces each
hexadecimal value with its respective 4-bit equivalent.

1. convert each hexadecimal digit into its decimal value

2. convert each decimal digit into a set of 4-bit code

Example 2.12. – Conversion from hexadecimal to binary system


Represent the hexadecimal number 3B16 into a binary code.

Step 1: convert each hexadecimal digit into its decimal value

3 B16

3 11
Step 2: convert each decimal digit into a set of 4-bit code

3 B16

3 11
0011 1011

Answer: 001110112 or 1110112

Exercise 2.6 – conversion from hexadecimal system to binary system


Convert the following hexadecimal numbers into its respective binary code
a. 1C816
b. 23016
c. D5E16

15 | P a g e
2.5.5. Conversion from binary to octal system
Since each digit of the octal system present a 3-bit group, then the conversion from binary to octal
system is done by replacing each octal digit with its respective 3-bit equivalent.

1. Identify the LSB and MSB, and break the binary code into 3-
bit groups from the LSB to the MSB

2. If the last group does not have 3 bit in the group, fill the bit
place with “0” up to 3-bit

3. Convert each group of 3-bit into its decimal value

Example 2.13. – Conversion from binary system to octal system


Convert the following binary code into octal code
Step 1: Identify the LSB and MSB, and break the binary code into 3-bit groups from the LSB to the
MSB

11 010 1012
(LSB)
(MSB)
Step 2: If the last group does not have 3 bit in the group, fill the bit place with “0” up to 3-bit

011 010 1012


(LSB)
(MSB)
Step 3: convert each group of 3-bit into its decimal value

011 010 1012


3 2 5

Answer: 3258

16 | P a g e
Exercise 2.7 – conversion from binary system to octal system
Convert the following binary code into octal code
a. 10001112
b. 10110001012
c. 111101002

2.5.4. Conversion from octal system to binary system


Conversion from octal number to binary number is also a straightforward method since each octal digit
is also an equivalent decimal value. It replaces each octal value with its respective 3-bit equivalent.

Example 2.14. – Conversion from octal system to binary system


Represent the octal number 258 into a binary code.
Step 1: convert each octal digit into a set of 3-bit code

2 58
2 5
010 101
Answer: 0101012 or 101012

Exercise 2.8 – conversion from octal system to binary system


Convert the following octal system into a binary code
a. 358
b. 1068
c. 4278

17 | P a g e
Alphanumeric Coding
When numbers, letters, or words are represented by a special group of symbols, we say that they are being
encode, and the group of symbols is called a code. Basically, encoder is an electronic device used to
convert an analogue signal to a digital signal such as Binary-Coded-Decimal, BCD, code. On the other
hand, the process of converting a digital signal such as binary code into words or symbols is called
decoder.
Most microcomputers handle and store binary data and information in groups of eight bits, so a special
name is given to a string of eight bits as byte. Also, binary numbers are often broken down into groups of
4-bits such as in BCD and hexadecimal. In the early days of digital systems, a term caught on to describe
a group of four bits is nibble. A word is a group of bits that represents a certain unit of information. The
word size can be defined as the number of bits in the binary word that a digital system operates on.

2.6. Binary-Coded-Decimal (BCD)

Binary coded decimal (BCD) is a way to express each of the decimal digits with a binary code. Since a
decimal digit can be as large as 9, four bits are required to code each digit (the binary code for 9 is 1001).

Decimal value 4-bit BCD code


0 0000
1 0001
2 0010
3 0110
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

There are only ten code groups in the BCD system, so it is very easy to convert between decimal and
BCD. Since we like to read and write in decimal, the BCD code provides an excellent interface to binary
systems. Examples of such interfaces are keypad inputs and digital readouts.
To illustrate the BCD code, take a decimal number such as 87410. Each digit is changed to its binary
equivalent as follows:

8 7 4
1000 0111 0100 (BCD)
The BCD system offers relative ease of conversion between machine-readable and human-readable
numerals. As compared to the simple binary system, however, BCD increases the circuit complexity. The

18 | P a g e
BCD system is not as widely used today as it was a few decades ago, although some systems still employ
BCD in financial applications.

Exercise 2.9 – Binary-Coded-Decimal (BCD)

Convert the following decimal number into its BCD code:


a. 70310
b. 9510
c. 246010

2.7. ASCII Code - The extended ASCII table


Information retrieved from Digital Electronics a practical approach with VHDL (The ASCII Code, 2012)

To get information into and out of a computer, we need more than just numeric representations; we also
have to take care of all the letters and symbols used in day-to-day processing. Information such as names,
addresses, and item descriptions must be input and output in a readable format. But remember that a digital
system can deal only with 1s and 0s. Therefore, we need a special code to represent all alphanumeric data
(letters, symbols, and numbers).
Most industry has settled on an input/output (I/O) code called the American Standard Code for Information
Interchange (ASCII). The ASCII code uses 7 bits to represent all the alphanumeric data used in computer
I/O. Seven bits will yield 128 different code combinations, as listed in Table 2.1.

Table 2.1 – ASCII Code Chart

Each time a key is depressed on an ASCII keyboard, that key is converted into its ASCII code and
processed by the computer. Then, before outputting the computer contents to a display terminal or printer,
all information is converted from ASCII into Standard English.

19 | P a g e
For example, if we type the word “May” from the computer keyboard, the computer processor will read
the following 7-bit character ASCII code in hexadecimal:

4D 61 79ASCII

References
ASCII Code. (n.d.). Retrieved from ASCII Code - The extended ASCI table: https://www.ascii-code.com
Engineering and Technology History Wiki. (n.d.). Engineering and Technology History Wiki. Retrieved from
Binary Numbers and Binary Math: ethw.org/Binary_Numbers_and_Binary_Math
The ASCII Code. (2012). In W. Kleitz, Digital Electronics a Practical Approach with VHDL (pp. 18-19). Pearson.

20 | P a g e

You might also like