Chapter 2
Chapter 2
Representation.
– 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.
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
1 0 1 0 . 0 1 0 1
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
3 7 1 3 . 2 4 0 6
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
– 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
– 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
– 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