0% found this document useful (0 votes)
17 views33 pages

COAChapter 2

Uploaded by

hirpaadugna1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views33 pages

COAChapter 2

Uploaded by

hirpaadugna1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

CHAPTER 2

Data representations in computers and


Number system

1
 Data in computers is represented in binary form. The
represented data can be number, text, movie, colour
(picture), sound, or anything else.
 Computers understand and respond to only the flow

of electrical charge.
 Data representation using the binary number system

results in a large string of 0s and 1s. This makes the


represented data large and difficult to read.

2
1. Non-positional number system
e.g. roman No. I, II, III
 The value of a symbol (digit) in a number does not

depend on the position of the digit in number.


2. Positional number system
e.g. binary, octal, hexadecimal and decimal
number.
 The value of a symbol in the number is determined

by its position, the symbol and the base of the


number system.
3
 Decimal number system
 called the base 10 number system
 It has 10 different symbols identified as 0, 1, 2, 3, 4,

5, 6, 7, 8, and 9.
 Binary number system
 known as base 2 number system,
 has two digits 0 and 1.

4
 Octal number system
 also called base 8 number system,
 has 8 different symbols: 0, 1, 2, 3, 4, 5, 6, and 7.
 Hexadecimal number system
 also called base 16 number system,
 has 16 different symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

A, B, C, D, E, and F.
 It is used to write binary numbers in short form.

5
1. Conversion from Decimal to Base m
Step 1: Divide the given decimal number by m (the
desired base).
The result will have a quotient and a remainder.
Step 2: Repeat step 1 until the quotient becomes 0,
the quotient is 0 whenever the number < m.
Step 3: Collect and arrange the remainders in such a
way that the first remainder is the least significant digit
and the last remainder is the most significant digit.

6
Eg: Convert the decimal number 47 into binary,
octal, and hexadecimal.
a. Conversion to binary divide by 2.

7
Hence the result is 1011112.

b. Conversion to octal: Here the numbers are divided


by 8

8
Therefore, 47 = 578
c. Conversion to hexadecimal
numbers are divided by 16.

The hexadecimal equivalent for the decimal 15 is F and


that of 2 is2.
Therefore, 47 = 2F16

9
2. Conversion from Base m to Decimal
Step 1: Multiply each digit by its positional value.
Step 2: Calculate the sum of the products you get in
step 1.
Example 1: Convert the binary number 110001 into
decimal.
1100012 = (1 × 25) + (1 × 24) + (0 × 23) + (0 × 22)
+
(0 × 21) + (1 × 20) = (1 × 32) + (1 × 16) + (0 × 8) +
(0 ×
4) + (0 × 2) + (1 × 1) = 32 + 16 + 0 + 0 + 0 + 1 = 49
🞂 ​ Therefore, 1100012 = 49.
10
Example 2: Convert the octal number 22 into decimal.
228 = (2 × 81) + (2 × 80) =
(2 × 8) + (2 × 1) = 16 + 2 = 18
Therefore, 228 = 18
Example 3: Convert the hexadecimal number D1 into
decimal.
D116 = (13 × 161) + (1 × 160)
Therefore, D116 = 209

11
3. Conversion from Binary to Octal
 It is possible to use decimal number system as an
intermediate base to convert from any base to any
other base. However, for conversion from binary to
octal or vice versa, there is a very simple method.
.

12
Step 1: Group the binary digits (bits) starting from
the rightmost dig into 3 bits.
If the remaining bits at the leftmost position are fewer than
3, add 0s at the front.
Step 2: For each 3-bit binary string, find the corresponding
octal number
Example: Convert the binary numbers 110011 and
1101111 to octal.

13
 The bits are grouped in three with the equivalent octal
digit given below the three bit group.
Thus, 1100112 = 638
The result is 11011112 = 1578.
4. Conversion from Octal to Binary
Step 1: For each octal digit, find the equivalent three
digit binary number.
Step 2: If there are leading 0s for the binary equivalent of
the leftmost octal digit, remove them.

14
Example: Find the binary equivalent for the octal
numbers 73 and 160.

15
 Therefore, 738 = 1110112 and
 Thus, 1608 = 11100002

5. From Binary to Hexadecimal


🞂​ One possible way to convert a binary number
to hexadecimal, is first to convert the binary number
to decimal and then from decimal to hex.
🞂 ​ The simple steps states are stated below.

16
Step 1: Starting from the rightmost bit, group the bits in 4. If
the remaining bits at the leftmost position are fewer than 4,
add 0s at the front.
Step 2: For each 4-bit group, find the corresponding
hexadecimal number.
Example: Convert the binary numbers 10011110 to
hexadecimal.

17
Therefore, 100111102 = 9E16
6. Conversion from Hexadecimal to Binary
Step 1: For each hexadecimal digit, find the
equivalent four digit binary number.
Step 2: If there are leading 0s for the binary
equivalent of the leftmost hexadecimal digit, remove
them.

18
🞂 ​ Example: Find the binary equivalents for the hexadecimal
numbers 1C and 823

🞂​ Thus, 1C16 = 111002 and 82316 = 1000001000112

19
7.Conversion from Octal to Hexadecimal of
Vice Versa
🞂 ​The decimal number system can be used as an
intermediate conversion base.
🞂​ second alternative is using the binary number
system as an intermediate base.
Step 1: Convert the given number into binary.
Step 2: Convert the binary number you got in step 1
into the required base.

20
🞂 ​ Example : Convert the octal number 647 to hexadecimal.

Therefore, 6478 = 1A716

Hence, 82316 = 1000001000112.

21
8. Conversion from Octal to Hexadecimal or Vice
Versa
Example 2: Find the octal equivalent for the
hexadecimal number 3D5

Therefore, 3D516 = 17258

22
 If the numbers we want to represent are only positive
(unsigned) integers,
 simply represent the unsigned integer with its binary
value.
 Signed integer representations are sign
magnitude, 1’s complement and 2’s complement.

23
 treat the most significant bit as a sign bit the
remaining bits are used to represent the magnitude of
the integer.
 a 0 on the sign bit indicates the integer is positive
and a 1 indicates the integer is a negative.
 As example, the sign-magnitude
representation of 79 and -79 in 8 bits are
01001111 and 11001111 respectively.

24
 Every number system has two complement systems.
For a given base n the complements are n’s
complement and (n-1)’s complement.
 The one’s complement of a binary integer is found by

inverting all 0s to 1s and all 1s to 0s. In one’s


complement integer representation, the negative of an
integer is represented by its complement.

25
For example, the one’s complement representation of
16 and -16 in 8 bits are 00010000 and 11101111
respectively.
For 8-bits number system:
🞂 ​Largest Positive Number: 0 1111111= +(127)10
🞂 ​Largest Negative Number: 1 0000000 =-(127)10

26
🞂 ​The two’s complement of an integer is found by
adding 1 to its one’s complement
🞂 ​ Example,
two’s complement representation of 19 and -19 in
8
bits are 00010011 and 11101101 respectively.

27
 Floating Point representation of a number has two
parts. The first part represents a signed, fixed-point
number called the mantissa.
 The second part designates the position of the

decimal (or binary) point and is called the exponent.


Floating point is always represented as follows:
 m x re where, m (mantissa) r(radix)
and e(exponent)

28
Binary Coded Decimal (BCD)
🞂 ​The BCD (Binary Coded Decimal), also called packed
decimal, in order to have representations for the ten digits
of the decimal number system, we need a four bit string.
🞂 ​ Notes: BCD is not equivalent to binary. Binary uses only
two digits (0 and 1), while decimal uses ten digits (0-9).
BCD is often used in digital systems that require precise
decimal arithmetic, such as calculators, cash registers, and
accounting systems.

29
 Characters refer to a unit of Information that
roughly corresponds to represent unit, or symbol,
letter, number.
 Examples of characters are, letters of the alphabet,
the ten digits (0 through 9), punctuation marks
Whitespace.

30
 characters that are used to format the layout of text on
pages such as the newline, space, and tab characters, and
other characters that are useful for communication.
 Characters are typically combined into String.
 ASCII is example of characters.

31
 each character is represented by 7 bits; hence a total
of 128 characters are represented.
 The eighth bit is used for parity (error detection).
 ASCII: 7-bit, plus a parity bit for error detection

(odd/even parity).

32
 Another character encoding system is the EBCDIC.
 It uses 8 bits per character (and a ninth parity bit),

thus represents 256 characters.


 EBCDIC is compatible with BCD.

33

You might also like