IIP Online Class
Chapter (1)
Data Representation
Computer Science Department
Institute of International
Professionalism
Data & Information
• Data is number, symbols or alphanumeric characters
in their raw format before processing
• Information is organized or classified data, which has
some meaningful values for the receiver.
• Analogue data as human we use, such as sound or
light waves and impulses on our skin.
• Computers are only capable of processing digital
data.
• Any data that we want a computer to process must
first be converted into digital data.
Denary and Binary Number
• Denary number system is in our daily lives we used. A system of
numbers uses the digit 0-9 and it is called a base-10 number
system.
• Each unit used increases by the power of 10.
• Computer use a binary number system,
• Binary number system uses the digit 0 and 1 and is called a base-2
number system.
• Binary is a mathematical number system, another way of counting
that is done by a computer. All of our data is read by the
computer as binary.
• Binary value represents the current flowing through a circuit: 1
means current is flowing, 0 means it is not.
• Each unit used increases by the power of 2.
• successive subtraction of powers of 2
• in each stage, subtract the largest possible power of
2 and keep doing this until the value 0 is reached
Binary addition
• In binary addition carry over is needed if the result is greater than 1
• Overflow Error , this condition occurs when a calculation produces a
result that is greater than the computer can deal with or store.
1 1 0 1 0 1 1 0
0 1 1 0 0 1 1 1
1 0 0 1 1 1 1 0 1
(carry over)
Overflow error
• The maximum denary value of an 8-bit binary
number is 255 (which is 28 – 1).
• The generation of a 9th bit is a clear indication that
the sum has exceeded this value.
• This is known as an overflow error and in this case
is an indication that a number is too big to be
stored in the computer using 8 bits.
• The type of error that occurs when a number larger
than a register can store is generated.
Binary addition
• 10011010 + 11010111
• 00001101 + 10101010
• 11010111 + 10001010
Sign-and-Magnitude (SM)
(Knowledge)
• If the sign bit is “0”, the number is positive. If the sign bit is “1”, then the
number is negative.
• The remaining bits in the number are used to represent the magnitude
of the binary number in the usual unsigned binary number format way.
Positive Signed Binary Numbers Negative Signed Binary Numbers
Sign-and-Magnitude (SM)
(Knowledge)
• If we have 4 bits to represent a signed binary number, (1-bit for the
Sign bit and 3-bits for the Magnitude bits).
4-bit Signed Binary Number
Comparison
4-bit Signed Binary Number
Comparison
Two’s Complement (Method-1)
• To find −109
• 128-109 = 19
• Put 1 at 128 for negative sign
128 64 32 16 8 4 2 1
1 0 0 1 0 0 1 1
• -128+16+2+1 = -109
Two’s Complement (Method-1)
• To find −28
• 128−28 = 100
• Put 1 at 128 for negative sign
128 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
• -128+64+32+4=-28
Two’s Complement (Method-1)
• To find −67
• 128−67 = 61
• Put 1 at 128 for negative sign
128 64 32 16 8 4 2 1
1 0 1 1 1 1 0 1
• -128+32+16+8+4+1=-67
Two’s Complement (Method-2)
• Step 1: Write the absolute value of the given number in
binary form. Prefix this number with 0 indicate that it is
positive.
• Step 2: Take the complement of each bit by changing zeroes
to ones and ones to zero.
• Step 3: Add 1 to your result. This is the two’s complement
representation of the negative integer.
Two’s Complement (Method-2)
1. Convert to binary value without sign
2. Flip 1 to 0, 0 to 1
3. Add 1 +1
Two’s Complement (Method-2)
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
69 0 1 0 0 0 1 0 1
Flip 1 0 1 1 1 0 1 0
Add 1 1 0 1 1 1 0 1 1
EXAMPLE: Find the two’s
complement of -17 with
method-2
• Step 1: 1710 = 0001 00012
• Step 2: Take the complement: 1110 1110
• Step 3: Add 1: 1110 1110 + 1 = 1110 1111.
• Find the two’s complement for
a. -11
b. -43
c. -123
Two’s Complement Binary
Back To Base Ten
• Step 1: Subtract 1: 1110 1111 - 1 = 1110 1110
• Step 2: Take the complement of the complement: 0001 0001
• Step 3: Change from base 2 back to base 10 :16 + 1 = 17
• Step 4: Rewrite this as a negative integer: -17
Two’s Complement
Binary Subtraction
• 95 – 68
First convert the two numbers into binary: 95 = 0 1 0 1 1 1
11
68 = 0 1 0 0 0 1 0 0
Now find the two’s complement of 68: 10111011
+1
−68 = 1 0 1 1 1
100
The additional ninth bit is simply ignored leaving the binary number: 0 0 0 1 1 0 1
1 (denary equivalent of 27 which is the correct result of the subtraction).
Logical binary shifts
The left-most bit is
referred to as the MOST
SIGNIFICANT BIT
The right-most bit is often
referred to as the LEAST
SIGNIFICANT BIT
Logical Shift
• Multiple shift left
e.g: multiple 22 means shift left two places
• Divided shift right
Eg: divided 22 means shift right two places
Arithmetic right Shift
(Knowledge)
• Each bit is moved one right
• The least significant bit(right most) is discarded
• The most significant bit is copied to the left hand side
• Repeat for the number of shift required
Arithmetic right Shift
(Knowledge)
a) 10010000 / 22
b) 11110110 / 21
c) 11000000 / 23
Measuring Memory Size
Unit Name Memory Value
1 Bits (b) A single 1 or 0
1 Nibble 4 Bits
1 Byte (B) 8 Bits
1 KB (Kilobyte) 1024 Bytes
1 MB (Megabyte) 1024 KB
1 GB (GigaByte) 1024 MB
1 TB (TeraByte) 1024 GB
1 PB (PetaByte) 1024 TB
1 EB (ExaByte) 1024 PB
Thank You !!