Lecture 2
Number Systems
Presentation Layout
Introduction
Number conversion
Hexadecimal System
Usefulness of the Hexadecimal System
Questions
Conclusion
Lesson Objectives
At the end of the lecture the student should be able to:
• Recognize the basic characteristics of the decimal number system,
binary system, octal and hexadecimal systems.
• Count in the decimal number system, binary system, octal and
hexadecimal systems.
• Convert a number from one number system (decimal, binary,
octal, hexadecimal) to its equivalent in one of the other number
systems.
• understand the advantages of the octal and hexadecimal number
system.
Number System
• Number system is a basis for counting varies items.
Modern computers communicate and operate with binary
numbers which use only the digits 0 &1.
• Basic number system used by humans is Decimal
number system.
• The decimal system is clearly the most familiar to us
because it is a tool that we use every day.
• The number systems used in computing are:
• binary, octal and hexadecimal systems.
Number System ctd
• To define any number system we have to specify
• Base or Radix (r) of the number system such as 2,8,10 or
16.
• The base decides the total number of digits available in
that number system.
• First digit in the number system is always zero and last
digit in the number system is always base-1.
Decimal System
• Also known as the Denary system
• The decimal system is composed of 10 numerals or
symbols or decimal digits
• The decimal system, also called the base-10 system because
it has 10 digits, has evolved naturally as a result of the fact
that people have 10 fingers.
• The word digit is derived from the Latin word for “finger.”
• These 10 symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; using these
symbols as digits of a number, we can express any quantity.
Decimal System ctd
• The decimal system is a positional-value system in which the value
of a digit depends on its position(weight).
• For example, consider the decimal number 453.
• The digit 4 represents 4 hundreds = 400
• the 5 represents 5 tens = 50,
• the 3 represents 3 units = 3
• The 4 (the leftmost digit )carries the most weight of the three
digits; it is referred to as the most significant digit (MSD).
• The 3(the rightmost digit) carries the least weight and is called the
least significant digit (LSD).
Decimal System ctd
• The various positions relative to the decimal point
carry weights that can be expressed as powers of 10.
• number of items that a decimal number represent:
• Decimal fraction
• 27.35 = (2 × 1 + (7 × ) + (3 × ) +(5 × ).
• Decimal point used to separate the integer and
fractional part of the number.
Decimal System ctd
• Formal notation
• 10
• 27.3510
Binary System
• In binary system, the term binary digit is often called
bit.
• The binary number has a radix of 2. As r = 2,
• only two digits(bits) are needed, and these are 0 and 1.
• In binary system weight is expressed as power of 2.
• The binary system, also called the base-2 system
• Binary number is also positional–value system (power
of 2).
Binary System ctd
Binary System ctd
• The left most bit, which has the greatest weight is
called the Most Significant Bit (MSB).
• And the right most bit which has the least weight is
called Least Significant Bit (LSB).
BINARY-TO-DECIMAL
CONVERSIONS
• Any binary number can be converted to its decimal
equivalent simply by summing together the weights
of the various positions in the binary number that
contain a 1.
• convert 110112 to its decimal equivalent.
BINARY-TO-DECIMAL
CONVERSIONS
Exercise
• Convert the binary numbers to decimal
• 100101
• 1010.011
• In general, any number (decimal, binary, octal and
hexadecimal) is simply the sum of products of each digit
value and its positional value.
• Binary values at the output of digital system must be
converted to decimal values for presentation to the
outside world.
• Decimal values must be converted into the digital
system.
• Group of 8 bits are called a byte.
Octal Numbering System
• Octal systems use base 8 or radix 8.
• Positional value system
• It uses first eight digits of decimal number system. Thus it has
digits from 0 to 7.
• Note: octal number don’t use digits 8 or 9
• Consider this octal number; 27.31.
• This number is equal to (2 × 81) + (7 × 80) + (3×8-1) +(1 × 8-2).
• each octal digit represents a group of 3 binary digits
Octal Binary
code
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
HEXADECIMAL NUMBER SYSTEM
• The hexadecimal number system uses base 16 Radix 16. Thus, it has 16 possible
digit symbols.
• It uses the digits 0 through 9 plus the letters A, B, C, D, E, and F as the 16 digit
symbols.
• For hex numbers the digits 10, 11, 12, 13, 14, 15 are represented by A, B, C, D, E, F
• The digit positions are weighted as powers of 16 , rather than as powers of 10 as in
the decimal system.
HEXADECIMAL NUMBER
SYSTEM
• Note that each hexadecimal digit represents a
group of four binary digits.
• It is important to remember that Hex or H
(abbreviation for “hexadecimal”) digits A through
F are equivalent to the decimal values 10 through
15.
• The table shows the relationships among hexadecimal,
decimal, Octal and binary.
Convert a number from one number system to another
• Way we need conversion?
• We need decimal system for real world (for presentation
and input): for example: we use 10-based numbering
system for input and output in digital calculator.
• We need binary system inside calculator for calculation.
DECIMAL-TO-BINARY CONVERSIONS
There are two ways to convert a decimal whole number
to its equivalent binary-system representation.
• The reverse of the binary-to-decimal conversion process
• Repeated Division
DECIMAL-TO-BINARY CONVERSIONS
ctd
• The reverse of the binary-to-decimal conversion
process
• The decimal number is expressed as a sum of powers of
2, and then 1s and 0s are written in the appropriate bit
positions.
Note that a 0 is placed in the 21 and 24 positions, since all positions
must be accounted for
DECIMAL-TO-BINARY
CONVERSIONS ctd
• Exercise
• Convert the decimal numbers to binary
numbers
• 70
• 45
DECIMAL-TO-BINARY CONVERSIONS ctd
• Repeated Division method
• Repeating division the decimal number by 2 and
writing down the remainder after each division until
a quotient of 0 is obtained.
• The conversion, illustrated for 2510, requires repeatedly
dividing the decimal number by 2 and writing down the
remainder after each division until a quotient of 0 is obtained.
• Note that the binary result is obtained by writing the first
remainder as the LSB and the last remainder as the MSB.
Conversion from a Whole
decimal number to other base
• 1. Divide decimal number by the base (2, 8, 16,
…).
• 2. The remainder is the lowest-order digit.
• 3. Repeat first two steps unit no divisor remains.
Decimal fraction conversion to
anther base
• Multiply decimal number by the base (2, 8,…).
• 2. The integer is the highest-order digit.
• 3. Repeat first two steps until fraction becomes
zero.
Exercise
• Convert decimal 25 to binary
• Convert 23.10 decimal to binary
• Convert binary10111.101 to decimal
Octal to Decimal conversion
Ex: convert 4057.068 to decimal
• =4x83+0x82+5x81+7x80+0x8-1+6x8-2
• =2048+0+40+7+0+0.0937
• =2095.093710
Decimal to Octal Conversion
• Ex: convert 378.9310 to octal
• 37810 to octal: Successive division:
Octal to binary Conversion
Exercise
• Convert 123 octal to binary
• Convert 3456.34 to binary
• Convert 101101binary to octal
• Convert 1101.101 binary to octal
Decimal-to-Hex Conversion
• Decimal-to-hex conversion can be done using
repeated division by 16
• Note that the remainders of the division processes form the
digits of the hex number.
• Note that any remainders that are greater than 9 are represented
by the letters A through F.
Hex-to-Binary Conversion
• The hexadecimal number system is used primarily
as a “shorthand” method for representing binary
numbers.
• It is a relatively simple matter to convert a hex
number to binary. Each hex digit is converted to its
four-bit binary equivalent
Binary-to-Hex Conversion
• Conversion from binary to hex is just the reverse of
the process .
• The binary number is grouped into groups of four bits,
and each group is converted to its equivalent hex digit.
• Zeros (shown shaded) are added, as needed, to
complete a four-bit group.
• To perform these conversions between hex and binary,
it is necessary to know the four-bit binary numbers
(0000 through 1111) and their equivalent hex digits.
• Once these are mastered, the conversions can be
performed quickly without the need for any
calculations.
• This is why hex is so useful in representing large
binary numbers.
Exercise
• Convert hex number AB23.CD to:
• binary
• decimal
• Convert binary 11011.101 to Hex
• Convert decimal number 290 to Hex
Counting in Hexadecimal
• When counting in hex, each digit position can be incremented
(increased by 1) from 0 to F.
• Once a digit position reaches the value F, it is reset to 0, and the next
digit position is incremented.
• 39, 3A, 3B, 3C, 3D, 3E, 3F, 40, 41, 42
• 6F8, 6F9, 6FA, 6FB, 6FC, 6FD, 6FE, 6FF, 700
• Note that when there is a 9 in a digit position, it becomes an A when it
is incremented.
• With N hex digit positions, we can count from decimal 0 to for a total
of 16N -1 different value.
• For example, with three hex digits, we can count from 000 16 to FFF16,
which is 010 to 409510, for a total of 4096 = 163 different values
Importance of Binary
Numbering System
• A computer is built from many connections and components.
• Data is transferred, stored and communicate with these
components.
• The electronic components use binary/digital signals to store,
transfer or communicate data.
• Computer electronic components are made up of tiny
switches that are either on or off so when the switch is on use
binary number 1 when the switch is off use binary number 0.
Importance of Binary
Numbering Systems ctd
• The electronic components consist of transistors
(semiconductor) that are used to amplify or switch
electronic signals (small switches).
• The use of binary system simplifies the design of
the computer system and its components.
Importance of Octal
Numbering Systems
• an abbreviation of binary because the bit size
(amount of bits that could be handled at one go).
• Using an octal number instead of a binary number
saves digits
• The use of octal in today’s computing environment
is in Linux or UNIX file and directory permissions
Usefulness of Hex
• Hex is often used in a digital system as sort of a
“shorthand” way to represent strings of bits. In
computer work, strings as long as 64 bits are not
uncommon.
• These binary strings do not always represent a
numerical value, but—as you will find out—can be
some type of code that conveys non-numerical
information.
Usefulness of Hex ctd
• When dealing with a large number of bits, it is
more convenient and less error-prone to write the
binary numbers in hex
• it is relatively easy to convert back and forth
between binary and hex.
• The octal and hexadecimal number systems are
both used (in memory addressing and
microprocessor technology).
Questions
• Convert the following binary number to decimal.
• 10011
• Convert 1000110110112 to its decimal equivalent. What is the weight of the
MSB of a 16-bit number?
• Convert 8310 to binary using both methods.
• Convert 72910 to binary using both methods. Check your answer by
converting back to decimal.
• Convert 24CE16 to decimal.
• Convert 311710 to hex, then from hex to binary.
• Convert 10010111101101012 to hex.
• Write the next four numbers in this hex counting sequence: E9A, E9B, E9C,
E9D, _____, _____, _____, _____.
• Convert 3527 to binary16.