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

Chapter 2

ghuuuu

Uploaded by

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

Chapter 2

ghuuuu

Uploaded by

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

CH 2: Data

Representation.

Er. Riddhish Uniyal


Contents

– Introduction
– Digital number system
– Number Conversions
– Represented Unsigned Integers in Binary
– Binary Addition
– Character / String Representation
Data Representation.

– Many number systems are in use digital technologies that represent the digits
in various forms.
– The common ones are decimal, octal , binary and hexadecimal.
– We will discuss this in Ch 2.
Decimal system.

– Composed of 1,2,3,4,5,6,7,8,9 and 0.


– Deca means 10, base of this number system is 10.
– Evolved naturally as humans have 10 fingers.
– Positional value system eg. 25.12
2 5. 1 2
(2x10)+ (5x1)+ (1x1/10)+ (2x1/100)
Two tens Five ones One tenth Two hundredth

7 2 9
(7x100)+ (2x10)+ 9x1
Seven hundreds Two tens Nine units
Positional values in decimal
numbers.

2 5 1 2 . 1 9 7 1

10³ 10² 10¹ 10⁰ 10⁻¹ 10⁻² 10⁻³ 10⁻



Decim LSD
MSD al point
Most Least
significant
significant
digit
digit
Binary Number system.

– Decimal system is hard to implement in digital systems.


– It is very difficult to design electronic equipment's with 10 different
voltage levels(0 through 9 for all decimal characters).
– In binary system it is hi voltage 1 or low voltage 0 hence very simple and
accurate to design.
– Most of digital systems use the binary number system.
Positional values in Binary system

1 0 1 0 . 0 1 0 1

2³ 2² 2¹ 2⁰ 2⁻¹ 2⁻² 2⁻³ 2⁻⁴

binary LSb
MSb point Least
Most significant
bit
significant
bit
NUMERICAL TYPE 1. Binary to Decimal
101011
2.Decimal to binary conversion.
Procedure:
– CONVERT TO BINARY: 13,106,84.
– CONVERT TO DECIMAL : 10010 , 101010 , 1010100.011
OCTAL NUMBER SYSTEM

– It is also a positional value system.


– Each octal digit has its own weight /
value expressed as power of 8.
OCTAL NUMBER SYSTEM

3 7 1 3 . 2 4 0 6

(8³ (8² (8¹ (8⁰ (8⁻¹ (8⁻² (8⁻³ (8⁻⁴

X3) X7) X1) X3)


X2) X4) X0) X6)

octal
point
DECIMAL TO OCTAL NUMBERS
HEXADECIMAL NUMBER
SYSTEM
– Uses digits 0 to 9 plus letters A,B,C,D,E,F as 16
digit symbols.
– Also a positional value system.
– Each hexadecimal digit has its own value and
weight expressed as power of 16.
HEXADECIMAL NUMBER SYSTEM

3 F A 3 . 2 4 C 6

(16³ (16² (16¹ (16⁰ (16⁻¹ (16⁻² (16⁻³ (16⁻



X3) X15 X10 X3)
X2) X4) X12) X6)
)
Hexade
cimal
point
Interconversion between number
systems.
– Binary to Hexadecimal.
– Hexadecimal to binary.
– Binary to Octal.
– Octal to binary.
– Hexadecimal to octal
– Octal to Hexadecimal
Binary to Hexadecimal procedure.

– We take a binary number in groups of 4 and use the appropriate hexadecimal digit in it’s
place.
– We begin at the rightmost 4 bits.
– If we are not able to form a group of four, insert 0s to the left until we get all groups of 4
bits each.
– Write the hexadecimal equivalent of each group.
– Repeat the steps until all groups have been converted.
Hexadecimal to Binary conversion
procedure
– Convert each digit of Hexadecimal Number to it’s binary equivalent
– Write them in 4 bits.
– Then, combine each 4 bit binary number
– And that is the resulting answer.
Hexadecimal to Binary conversion
procedure.
– Convert each digit of Hexadecimal Number to it’s binary equivalent
– Write them in 4 bits.
– Then, combine each 4 bit binary number
– And that is the resulting answer.
Binary to Octal and Octal to Binary
conversion procedure.
– To convert Binary to Octal, as the octal system is a power of two (2³).
– We can take the bits into groups of 3 and represent each group as an octal digit.
– The steps are the same for the binary to hexadecimal conversions except we are dealing
with the octal base.

– To convert from octal to binary, we simply represent each octal digit in it’s three bit
binary form.
Hexadecimal to Octal conversion
procedure.
– To convert Hexadecimal to Octal,
– Convert each digit of Hexadecimal Number to it’s binary equivalent .
– Write them in 4 bits.
– Then, combine each 3 bit binary number and that is converted into octal.
Octal to Hexadecimal conversion
procedure.
– To convert Octal to hexadecimal
– Convert each digit of Octal Number to it’s binary equivalent
– Write them in 3 bits.
– Then, combine each 4 bit binary number
– And that is converted into hexadecimal.
QUESTIONS type inter conversions
b/w 2 non decimal systems

– Convert (1948.B6)₁₆ to binary and octal equivalents.


– Convert (75643.5704)₈ to hexadecimal and binary numbers
Number Representation.
Questions for practice.

– Do as directed :
 Convert the Decimal number 781 to its Binary equivalent.
 Convert Binary number 101101.001 to its decimal equivalent.
 Convert Octal number 321.7 into its Binary equivalent
 Convert the Hexadecimal number 3BC into its Binary equivalent.
 Convert the Binary number 10011010.010101 to its Hexadecimal equivalent
 Convert the Decimal number 345 into Octal number.
 Convert the Decimal number 736 into Hexadecimal number.
 Convert the Octal number 246.45 into Hexadecimal number.
 Convert the Hexadecimal number ABF.C into Octal number.
 Convert the Octal number 576 to Decimal.
 Convert the Hexadecimal number A5C1 to Decimal.
Representing unsigned integers in
binary.
– An unsigned integer can be + integer or zero but never negative.
– In single decimal digit you can write a number between 0 and 9
– In double decimal digits, between 0 and 99(max)
– In triple decimal digits , between 0 and 999(max)
– 9=10¹-1
– 99=10²-1
– Hence in n decimal digits you can write a number between 0 and 10ᵑ-1.
– Similarly a n bit pattern can represent integers from 0 to 2ᵑ-1.
Binary Representation of
Integers
1. Binary number can be represented only by using 0’s and 1’s, but can not use the sign
(-)
2. To denote the negative number or sign (+) to denote the positive number. We use
either 0 or 1.
3. There are three methods to represent binary number. They are
(i) Sign and magnitude method
(ii) One’s complement method
(iii) Two’s complement method
Sign and magnitude method
In this method, first bit is considered as a sign bit. Here positive number starts with 0
and negative number starts with 1
EXAMPLE

– 25
– 25/2 = 12 1
– 12/2 = 6 0
– 6/2 = 3 0
– 3/2 = 1 1
– 1/2 = 0 1
– So the binary number is (11001) 2. If we take the size of the word is 1 byte, then the
– number 25 will be represented as 00011001
– Suppose, if the number is -25, and then it will be represented as
– 10011001
One’s Complement Method

– In this method, the positive number is represented as same as the binary number.
– If the number is negative, then we need to find one’s complement of a binary number.
– The one’s complement of a binary number will replace every 0 with 1 and vice- versa.
EXAMPLE

– Represent 86 in one’s complement method (I byte representation)


– 86/2 =43 0
– 43/2 =21 1
– 21/2 =10 1
– 10/2 =5 0
– 5/2 =2 1
– 2/2 =1 0
– 1/2 =0 1
– The binary number is 1010110
– 1 byte representation of number 86 is 0101001.
Represent -55 using 1’s
complement.
Two’s Complement method

– In this method, the positive number is represented as the binary number.


– If the number is negative, then we need to calculate two’s complement of a binary
number.
– The two’s complement of a binary number is calculated by adding 1 to its one’s
complement.
EXAMPLE

– Represent -54 two’s complement method (I byte representation)


– 54/2 =27 0
– 27/2 =13 1
– 13/2 =6 1
– 6/2 =3 0
– 3/2 =1 1
– 1/2 =0 1
– The binary number is 110110
– Hence, the 1 byte representation is 00110110
– The given number is negative; hence we need to calculate two’s complement.
– One’s complement of 00110110 is 11001001 (convert 1 into 0 and 0 into 1)
– Add 1 to one’s complement. Thus, 1 byte representation of number -54 is 11001010
Represent -77 two’s complement method
(I byte representation)
Binary addition.

– Binary addition is much like your normal everyday addition (decimal addition), except that it
carries on a value of 2 instead of a value of 10.For example: in decimal addition, if you add 8 +
2 you get ten, which you write as 10; in the sum this gives a digit 0 and a carry of 1.
Something similar happens in binary addition when you add 1 and 1; the result is two (as
always), but since two is written as 10 in binary, we get, after summing 1 + 1 in binary, a digit
0 and a carry of 1.
– Therefore in binary:
0+0=0
0+1=1
1+0=1
1 + 1 = 10 (which is 0 carry 1)

– Example. Suppose we would like to add two binary numbers 10 and 11. We start from the last
digit. Adding 0 and 1, we get 1 (no carry). That means the last digit of the answer will be one.
Then we move one digit to the left: adding 1 and 1 we get 10. Hence, the answer is 101. Note
that binary 10 and 11 correspond to 2 and 3 respectively. And the binary sum 101 corresponds
to decimal 5: is the binary addition corresponds to our regular addition.
ASCII
ISCII AND UNICODE

– ISCII: (Indian Standard Code for Information Interchange)


– A lot of efforts have gone into facilitating the use of Indian languages on computers. In
– 1991, the Bureau of Indian Standards adopted the ISCII. It is an 8 bit code which allows
– English and Indian Scripts alphabets to be used simultaneously. Characters coded in
– ISCII need 8 bits for each character.
– Unicode
– Unicode is a new universal coding standard adopted by all new platforms. It is
– promoted by Unicode Consortium which is a non profit organization. Unicode provides
– a unique number for every character irrespective of the platform, program and the
– language. It is a character coding system designed to support the worldwide
– interchange, processing, and display of the written texts of the diverse languages.

You might also like