Chapter 4 - Number system

advertisement
Chapter – 3
Number System
Every computer stores numbers letters and other special characters in the coded form. Before going into
detail with these codes, it is essential to have a basic understanding of number system. Hence in this
chapter we familiarize you with the fundamentals of number system. It also introduces some commonly
used number system by computer professionals and relationship among them.
 Understand the concept of number systems.
 Distinguish between non-positional and positional number systems.
 Describe the decimal, binary, hexadecimal and octal system.
 Convert a number in binary, octal or hexadecimal to a number in the decimal system.
 Convert a number in the decimal system to a number in binary, octal and hexadecimal.
 Convert a number in binary to octal and vice versa.
 Convert a number in binary to hexadecimal and vice versa.
1
Info Notes
Example 2.1
The following shows the place values for the integer +224 in the decimal system.
Note that the digit 2 in position 1 has the value 20, but the same digit in position 2 has the value 200.
Also note that we normally drop the plus sign, but it is implicit
Example 2.2
The following shows the place values for the decimal number −7508. We have used 1, 10, 100, and 1000
instead of powers of 10.
Note that the digit 2 in position 1 has the value 20, but the same digit in position 2 has the value 200.
Also note that we normally drop the plus sign, but it is implicit.
Example 2.3
The following shows the place values for the real number +24.13
2
Info Notes
Example 2.4
The following shows that the number (11001)2 in binary is the same as 25 in decimal. The subscript 2
shows that the base is 2.
The equivalent decimal number is N = 16 + 8 + 0 + 0 + 1 = 25
Example 2.5
The following shows that the number (101.11)2 in binary is equal to the number 5.75 in decimal.
Binary Numbers: 
1.
2.
3.
4.
5.
6.
7.
8.
The binary system uses base 2 to represent different values. Therefore, the binary
system is also known as base-2 system.
 As this system uses base 2, only two symbols are available for representing the
different values in this system. These symbols are 0 and 1, which are also know as
bits in computer terminology.
 Using binary system, the computer systems can store and process each type of data in
terms of 0s and 1s only. The following are some of the technical terms used in binary
system:
Bit: It is the smallest unit of information used in a computer system. It can either have the
value 0 or 1. Derived from the words Binary ditIT.
Nibble: It is a combination of 4 bits.
Byte: It is a combination of 8 bits.
Word: It is a combination of 16 bits.
Double word: It is a combination of 32 bits.
Kilobyte (KB): It is used to represent the 1024 bytes of information.
Megabyte (MB): It is used to represent the 1024 KBs of information.
Gigabyte (GB): It is used to represent the 1024 MBs of information
Decimal Numbers: 3
Info Notes






The decimal system is the most common number system used by human beings.
It is a positional number system that uses 10 as a base to represent different values.
Therefore, this number system is also known as base 10 number system.
In this system, 10 symbols are available for representing the values. These symbols
include the digits from 0 to 9. The common operations performed in the decimal
system are addition (+), subtraction (-), multiplication (), and division (/).
The decimal system can be used to represent both the integer as well as floating point
values. The floating point values are generally represented in this system by using a
period called decimal point.
The decimal point is used to separate the integer part and the fraction part of the given
floating point number.
The value of any number represented in the decimal system can be determined by
first multiplying the weight associated with each digit in the given number with the
digit itself and then adding all these values produced as a result of multiplication
operation.
Octal Numbers: 

The octal system is the positional number system that uses base 8 to represent
different values. Therefore, this number system is also known as base-8 system.
As this system uses base 8, eight symbols are available for representing the values in
this system. These symbols are the digits 0 to 7.
Hexadecimal Numbers: 


4
The hexadecimal system is a positional number system that uses base 16 to represent
different values. Therefore, this number system is known as base-16 system.
As this system uses base 16, 16 symbols are available for representing the values in
this system. These symbols are the digits 0-9, which are used to represent the decimal
values 0 through 9, and the letters A, B, C, D, E and F, which are used to represent
the decimal values 10 through 15
The weight associated with each symbol in the given hexadecimal number can be
determined by raising 16 to a power equivalent to the position of the digit in the
number.
Info Notes
Conversion among Bases: We need to know how to convert a number in one system to the equivalent number in another system.
Since the decimal system is more familiar than the other systems, we first show how to covert from any
base to decimal. Then we show how to convert from decimal to any base. Finally, we show how we can
easily convert from binary to hexadecimal or octal and vice versa
Conversions of Binary to Decimal: 

A binary number can be converted to equivalent decimal number by calculating the
sum of the products of each bit multiplied by its corresponding place value
Convert the binary number 10101101 into its corresponding decimal number.
(127)+(026)+(125)+(024)+(123)+(122)+ (021)+(120)
=128+0+32+0+8+4+0+1
=173
Conversions of Binary to Octal: -
5
Info Notes
Conversions of Binary to Hexadecimal: 




Converting from binary to hexadecimal entails reversing the procedure for converting from
hexadecimal to binary. Specifically, we can convert directly from binary notation to the
equivalent hexadecimal representation by using the following procedure:
Starting at the right, collect the bits in groups of 4
Convert each group of 4 bits into the equivalent hexadecimal digit
Concatenate the resulting hexadecimal digits
For example, to convert 110110101001 to hexadecimal, we collect the bits into groups of
4 starting at the right: 1101 1010 1001, and then we convert each collection of bits into a
hexadecimal digit:
1101 1010 1001
D
A
9
Thus 110110101001 = DA9
Conversions of Decimal to Binary: 

6
The decimal to binary conversion is performed by repeatedly dividing the decimal
number by 2 till the decimal number becomes zero and then reading the remainders
from last to first to obtain the binary equivalent to of the given decimal number.
Convert the decimal number 30 into its equivalent binary number.
Info Notes
Conversions of Decimal to Octal: 

The decimal to octal conversion is performed by repeatedly dividing the decimal
number by 8 till the decimal number becomes zero and then reading the remainders
form last to first to obtain the binary equivalent to of the given decimal number.
Convert the decimal number 45796 to its equivalent octal number.
Conversions of Decimal to Hexadecimal: 

The decimal to hexadecimal conversion is performed by repeatedly dividing the decimal
number by 16 till the decimal number becomes zero and then reading the remainders
form last to first to obtain the binary equivalent to of the given decimal number.
Convert the decimal number 1567 into its equivalent hexadecimal number.
7
Info Notes
Conversions of Octal to Decimal: 
An octal number can be converted into its equivalent number in decimal system by
calculating the sum of the products of each digit multiplied by its corresponding place value.

Convert the octal number 13256 into its equivalent in decimal systems.
(184)+(383)+(282)+(581)+(680)
=4096+1536+128+40+6
=5806
Conversions of Octal to Hexadecimal: 
The given octal number can be converted into its equivalent hexadecimal number in two
different steps:
o Convert the given octal number into its binary equivalent by representing each
digit in the octal number to its equivalent 3-bit binary number.
o Divide the binary number into 4-bit sections starting from the least significant bit.

Example: Convert the octal number 365 into its equivalent hexadecimal number.
Conversions of Hexadecimal to decimal: 

8
A hexadecimal number can be converted into its equivalent number in decimal
system by calculating the sum of the products of each symbol multiplied by its
corresponding place value.
Convert the hexadecimal number 6B39 into its equivalent in the decimal system.
(6163)+(11162)+(3161)+(9160)
=24567+2816+48+9
=27449
Info Notes
Download