0% found this document useful (0 votes)
3 views17 pages

Chapter 2 Encoding

The document discusses various encoding schemes used for character representation, including ASCII, ISCII, BCD, and Unicode. It explains how these encoding systems work, their character limits, and their applications in data transmission and representation. Additionally, it covers data types, signed and unsigned numbers, and arithmetic operations using different number representations like signed magnitude, 1's complement, and 2's complement.

Uploaded by

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

Chapter 2 Encoding

The document discusses various encoding schemes used for character representation, including ASCII, ISCII, BCD, and Unicode. It explains how these encoding systems work, their character limits, and their applications in data transmission and representation. Additionally, it covers data types, signed and unsigned numbers, and arithmetic operations using different number representations like signed magnitude, 1's complement, and 2's complement.

Uploaded by

Armin Shroff
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Ch 2- Encoding

Encoding is the system to represent a character in a specific format for efficient


transmission or storage.
Some Examples of Encoding Schemes
 ASCII
 ISCII - Indian
 BCD Binary coded decimal of 8-4-2-1 code
 UNICODE (rmbr ? Java’s character set)

ASCII To encode characters in a comp sys-ASCII


American Standard Code for Information Interchange
ASCII – 7  Represents 27=128 different characters
ASCII – 8  represents 28=256 different characters

65 = 1 0 0 0 0 0 1
66 0 0 1 0

97 0 1 1 0 0 0 0 1
ISCII Indian Standard Code for Information Interchange
ISCII is a coding scheme for representing various writing systems
of India. It encodes the main Indic scripts and a Roman
transliteration. It uses an 8-bit encoding scheme and includes
around 256 characters. The first 128 characters, numbered 0-127,
are the same as in ASCII.
It incorporates Matras to represent vowels and Halant sign
(conjuction of half alphabets.)
BCD Binary Coded Decimal: one of the oldest encoding schemes. Each
decimal digit is expressed in 4 bits (8-4-2-1)

BCD of a multi-digit number is a combination of the BCD codes of


each digit (15)10 = (0001 0101) bcd

Zones are added to represent other characters /symbols.


Zone: 00 for digits 0 to 9
11 for A to I
10 for J to R
01 for S to Z

So, BCD becomes a 6 bit representation =2 zone bits + 4 code digit


This can then be read as an Octal too.
A = 11 0001 = in octal by grouping 61

UNICODE Universal Code


A fixed-length world wide character encoding standard.
Capable of encoding characters from every language in the world(all
chars from all scripts, all symbols .. consortium of all encoding
schemes)
Unicode uses two encoding forms: 8-bit and 16-bit, based on the
data type of the data that is being that is being encoded. The default
encoding form is 16-bit, where each character is 16 bits (2 bytes)
wide.
*Zone
Bits "zone bits" refer to specific bits within the coding standard that
help categorize characters into different groups or "zones."
Eg. ASCII Zone Bits to divide characters into several zones based on their bit patterns:

Control Characters (Zone 0): Characters with ASCII codes ranging from 0 to 31 (decimal)
are control characters. These characters are non-printable and represent functions
such as carriage return, line feed, escape, and others.

Printable Characters (Zone 1): Characters with ASCII codes ranging from 32 to 126
(decimal) are printable characters. They include alphanumeric characters, punctuation
marks, and special symbols that can be displayed on screen or paper.

Extended Characters (Zone 2): Characters with ASCII codes ranging from 128 to 255
(decimal) are extended characters. These characters are used for various purposes,
including language-specific characters, special symbols, and graphics.

The "zone bits" concept refers to the bit positions within the ASCII code that help
identify which zone a character belongs to. Specifically, the most significant bit (bit 7) is
used to differentiate between characters in different zones. Characters in Zones 0 and 1
have a most significant bit of 0, while characters in Zone 2 have a most significant bit of
1. This bit-level classification is what allows software and systems to distinguish
between different types of ASCII characters.

Applications: data transmission in Networking / Data safety, reducing data size,


more organized and precise.

Data Representation
Data -> processing  information
Input – Process - Output
Data Process Information
Raw facts and figures Arrange, Meaningful data
56 Sort, manipulate, filter,
Pics, videos, calculate, compare
alphanumeric
External data
 Numeric: integer(whole) or real (floating point)
 Alphanumeric: [String] (date/time)
 Char: Alphabetic or special character

Internal Data
Bit, Nibble , Byte and Word

Eg:ABC = external data

100001/100001 0/0100 0011


Real numbers
 Unsigned number == positive
 Signed number [positive or negative]
1. Signed magnitude method msb =0 positive, msb=1 negative
2. Signed 1’s complement
3. Signed 2’s complement

Signed Magnitude Form


6
0 msb 0 1 1 0
+6
1 msb
-6
Msb
saved
for sign

1 1 1 1 1 1 1 1
neg
Largest negative number possible is - 127

-200
1 1 1 0 0 1 0 0 0

657 =
0 1 0 1 0 0 1 0 0 0 1
1
(neg)
32 = 00100000 - 100 11100100

(27)10 =

0 0 0 1 1 0 1 1
pos

(-27)10
1 0 0 1 1 0 1 1
neg
127 pos and neg [msb signed bit.. 0 positive , 1 negative]
0 (pos) 1 1 1 1 1 1 1
1(neg) 1 1 1 1 1 1 1

Therefore, Signed Magnitude n=8 , 8 bits = 1 byte


Maximum positive + 2 n-1 -1 =27-1 = +127
Maximum Negative – 2 n-1-1 = - 27-1 = - 127

255
0 1 1 1 1 1 1 1 1
pos
1 1 1 1 1 1 1 1 1
neg

1’s Complement Form

1’s complement of 10101111 is inverse/complement of


every bit 01010000
 Pos integer represented in its true form (binary equivalent)
 Every negative number  1’s complement form
Complement of 1 =0 and complement of 0 is 1
0 1 0 1 0 0 1 0 0 0 1
1
(neg)
1’s complement of (657)10
1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0

1’s complement Arithmetic [computer, subtraction is also done by


addition] A-B = C A+B’=C
10 – 4 = 6
10 +(-4) = 6
a) Addition of unsigned numbers as we normally do

Subtraction using 1st complement


1. Find 1’s complement of second number
2. Add it to the first one
3. If sum results in carry 1, then add it to the LSB of the sum
4. If no carry, then the same result 1’s complement of the
answer along with sign bit(1) -meaning negative number
15 – 9
15 0 0 0 0 1 1 1 1
9 0 0 0 0 1 0 0 1
1’s 1 1 1 1 0 1 1 0
compl
of 9
0 0 0 0 0 1 0 1
+1
1 1 0

10-23
10 0 0 0 0 1 0 1 0
23 0 0 0 1 0 1 1 1
23’ 1 1 1 0 1 0 0 0
1 1 1 1 0 0 1 0
Compl 1 0 0 0 1 1 0 1
The
ans

Eg: 7- 6
00000111 – 00000110 = 1 (no carry)

Eg: 10 - 5
0 0 0 0 1 0 1 0
1 1 1 1 1 0 1 0
0 0 0 0 0 1 0 0
1
1 0 1

545- 230
545 1 0 0 0 1 0 0 0 0 1
230 1 1 1 0 0 1 1 0
1’s 1 1 0 0 0 1 1 0 0 1
of
230
(1)0 1 0 0 1 1 1 0 1 0
1
315 1 0 0 1 1 1 0 1 1

27 - 56
27 1 1 0 1 1
56 1 1 1 0 0 0
1’s of 0 0 0 1 1 1
56
1 0 0 0 1 0
Again 1 1 1 0 1
1’s
compl
of the
answe
r
Signed 2’s Complement
*every positive number is represented as it is , while every negative is represented
in its 2’s complement form

Signed 2’s complement of 00001001 is obtained by adding 1 to its 1’s


complement
10011010 = 01100101+1=01100110
00001001  1’s complement = 11110110+1
2’s complement = 11110111
Maximum Positive +(2n-1) , Maximum Negative –(2n-1), where n is the number of
bits in a word.

2’s Complement Arithmetic


2’s complement subtraction

i. Find the 2’s complement of the second number


ii. Add the first and second number
iii. If carry is 1, then result is only the sum part(ignore the
carry)
iv. If no carry, then the ans will be find the 2’s
complement with a sign bit of 1 as MSB indicating
negative number.
45 – 23 in 2’s complement
0 0 0 1 0 1 1 0 1
0 0 0 0 1 0 1 1 1
1 1 1 1 0 1 0 0 1
0 0 0 0 1 0 1 1 0

23-45
23 0 0 0 1 0 1 1 1
45 0 0 1 0 1 1 0 1
2’S 45 1 1 0 1 0 0 1 1
1 1 1 0 1 0 1 0
-22 0 0 0 1 0 1 1 0

98 – 55 : WILL BE A CARRY.. IGNORE AND THE ANS IS THE REMAINING PART


67-100 : NO CARRY.. .. FIND 2’S COMPLE OF THE ANS, -VE FORM

65-21 using 2’s complement


65 1 0 0 0 0 0 1
21 1 0 1 0 1
2’s com 1 1 0 1 0 1 0+1=1
of 21
44ans 0 1 0 1 1 0 0
55-100 using 2’s complement = 101101 = -45 - because MSB is 1
55 1 1 0 1 1 1
100 1 1 0 0 1 0 0
2’s co 0 0 1 1 0 (1) 1 (1) 1+1=
of 1 0 0
100
1 0 1 0 0 1 1
2’s 0 1 0 1 1 0 0+1=1
comp
bcoz
of no
carry

Real Numbers: Fixed Point or Floating Point


Fixed Point (Whole Numbers, decimal Floating Point (decimal point does not
point only at the end of the number) have a fixed position, hence called
5.0 floating)
Eg: Java:Int, byte, short, long 5.000001 50.0001 5000.44
4bytes, 0.000000011
Int x=5;
Eg. Integer 1001.0001
Overflow (larger value, truncation) Scientific Notation: has a single digit to
Underflow(smaller value, wastage) the left of the decimal point.
V v small/large number 1001.0001 =0.10010001 * 104
Adv : exact value , comparison
What is Scientific Notation..
For numbers with two high magnitude (extremely small or extremely huge)
that do not need precision (to avoid too many zeroes) like Inter-planetary
distance, network speed, 3X103mbps
Format : a X bn
[charge of electron 1.60X10-19 C , speed of light 2.9X108 m/s
290000000
Two parts : a is the mantissa , n is the exponent
In a before decimal, should be one digit 1>=a <b [so binary floating point in
scientific notation, will have leading digit always only 1]

b is the base (decimal=10, binary=2, octal=8 , hexa=16)


n, the exponent is a positive or negative number indicating movement of
decimal point to the left or right- governs the range

[Link]
v=YEttEC1osJw

123000 = 123X103 .123 /1000 = 123 X 10-3


0.0000333 normal formal = 333/1000000 = 3.33 x 10-6
12600000000.000 = 1.26X1010
Rule to form scientific notation is has two parts mantissa(a) and exponent (n),
and the value before decimal in a >=1 and < base
--------------
when deci pt is moving to the left, then the exponent is positive,
right, -----------------------negative
10001.111 normal binary to scientific notation binary = 1.0001111 X 24
11100011.0 = 1.1100011 X 27
0.001101 =1.101 X 2-3

10001.111 SCIENTIFIC a X 2n = 1.0001111 X24


(eg--45.67 4567X10-2 4567/100 = 45.67)

Scientific floating notation Normal floating notation


For eg: .0001001
1.001 X 10-4 1.001 X 1/10000 =

1001 1
1000 X 10000 =
1.0011001 X22 (100.11001)2
1.10111 X 21 (11.0111)2
1.01011 X 23 1010.11
<deci pt moving to the left, power is positive>
-6
1.11 X 2 0.00000111
<deci pt moving to the right, power is
negative>
1.00111 X 25 100111.0
1.10101010 X 2-4 1101.01010
110101010/10000 =

1.01011 X 23 1010.11
1.000011 X2-3 0.001000011

Floating Point Numbers Arithmetic


Addition Subtraction
i. Both numbers must be in same i. Equalize the exponent of both the
numbers as done in addition
notation form
ii. Convert second number into 1’s
ii. If exponents are different, shift complement and add it to the first
the deci pt of the number with one.
smaller exponent to the left to
have same exponent.
iii. Perform regular addition
iv. If sum has > 1 digit before
decimal point, keep only 1 digit
before deci pt, by adjusting
mantissa and exponent
1.0011 x 25
1.01 X 22 +

1.000 X 21 1.10011 x 27

0.010011
1.010 X 22 1.100110
0.100 X 22 1.111001 x 27

1.101 X 23 + 1.1001 X 24

0.1101 x 24
1.1001 x 24
10 . 0 1 1 0 x 24
5
1.00110 x 2
1.10101 X 23
0.1011 x 2-2
0.111 X 2-6 + 1.1001 X 2-4 1.10101000
0.00001011

0.00111
1.10010
1. 1 1 0 0 1 X 2-4
1.0101 X 24
1.110 X 23
0.1110
1.000 1 1 X2-1

1.1010 X 2-3
1.1111 X 22

0.000011010
1.1111
11010

1.001 X 24
1.010 X 22

1. 00 1
0. 01 010
1. 10101
0 .1 1 0 10

binary of (121)10 - binary of (55)10 using 1’s complement


step1: get the 1’s complement of the subtrahend 2nd number=B when a-
b
step2: add a and b’s 1’s complement
step3:if carry over, then add carry to the LSB of sum
step4: when no carry, take 1’s complement of sum and put -ve sign
64 32 16 8 4 2 1
121 1 1 1 1 0 0 1
55 1 1 0 1 1 1
55’s 1’s 1 0 0 1 0 0 0
Sum 1 0 0 0 0 0 1
Carry 1
added to
LSB of
sum
Ans=66 1 0 0 0 0 1 0

100-134
=(10100010)2 msb 1 means negative
128 64 32 16 8 4 2 1
100 0 1 1 0 0 1 0 0
134 1 0 0 0 0 1 1 0
134’s 0 1 1 1 1 0 0 1
comp
Sum 1 1 0 1 1 1 0 1
Re’compl= 1 0 0 0 1 0
-34

You might also like