Chapter 02-Part I
Chapter 02-Part I
Level I - Semester 1
7 6 5 4 3 2 1 0 Position
1 1 0 1 1 0 1 0
A byte represents a group of bits
Most Least
Significant Bit Significant Bit
• 8 Bits = 1 Byte
• 1024 Bytes = 1 Kilobyte (KB)
• 1024 KB = 1 Megabyte (MB)
• 1024 MB = 1 Gigabyte (GB)
• 1024 GB = 1 Terabytes (TB)
• 1024 TB = 1 Petabytes (PB)
• 1024 PB = 1 Exabyte
• 1024 EB = 1 Zettabyte
• 1024 ZB = 1 Yottabyte
2 8 3 7 5
102 101 100 10-1 10-2
123 11110112
÷2
61 → remainder 1
÷2
30 → remainder 1
÷2
15 → remainder 0
÷2
7 → remainder 1
÷2
3 → remainder 1
÷2
1 → remainder 1
÷2
0 → remainder 1
0.37510 = 0.0112
1 0 1 1 1
22 21 20 2-1 2-2
1 × 22 + 0 × 21 + 1 × 20 + 1 × 2−1 + 1 × 2−2
4 + 0 + 1 + 0.5 + 0.25
5.75
• Ex. 1100100111012
• Conversion to hexadecimal
1 1 0 0 1 0 0 1 1 1 0 1 Binary
C 9 D Hexadecimal
• Conversion to octal
1 1 0 0 1 0 0 1 1 1 0 1 Binary
6 2 3 5 Octal
• 0+0=0
• 0+1=1
• 1+0=1
• 1 + 1 = 10 (carry: 1)
• E.g.
11 1 1 1 (carry)
0 1 1 0 1
+ 1 0 1 1 1
= 10 0 1 0 0
• 0-0=0
• 0 - 1 = 1 (with borrow)
• 1-0=1
• 1-1=0
• E.g.
* * * (borrow)
1 0 1 1 0 1
- 0 1 0 1 1 1
= 0 1 0 1 1 0
• E.g.
1 0 1 1
x 1 0 1 0
0 0 0 0
+ 1 0 1 1
+ 0 0 0 0
+ 1 0 1 1
= 1 1 0 1 1 1 0
• E.g.
1 0 1 Quotient
1 0 1 1 1 0 1 1
- 1 0 1
1 1
- 0 0
1 1 1
- 1 0 1
1 0 Remainder
Sign bit
Negative
Source: https://en.wikipedia.org/wiki/Two%27s_complement
© 2020 e-Learning Centre, UCSC 32
Two’s Complement - Benefits
• Carry going into the sign bit (highlighted in green) is the same as
the carry going out of the sign bit (highlighted in yellow).
• In such a scenario, no overflow occurs.
• When these carries are different, an overflow indicator is set in
the arithmetic logic unit, indicating the result is incorrect.
• Carry going into the sign bit (highlighted in green) is 1 and the
carry going out of the sign bit (highlighted in yellow) is 0.
• Addition of two positive numbers has resulted a negative number.
• Carries are different in here and an overflow has occurred.
Correct
Operation Result Carry ? Overflow ?
Result ?
0100 + 0010 0110 No No Yes
([+4] + [-2] in decimal) (+6 in decimal)
7 x 10-3 = 7/1000
5 x 10-2 = 5/100
3 x 10-1 = 3/10
6 x 100 = 6
1 x 101 = 10
357
• 7/1000 + 5/100 + 3/10 + 6 + 10 =16
1000
1 * 2-3 = 1/8
1 * 2-2 = 1/4
0 * 2-1 = 0
0 * 20 = 0
1 * 21 = 2
3
• 1/8 + 1/4 + 2 =2
8
3
• (10.011)2 = 2 in Decimal (Base 10)
8
© 2020 e-Learning Centre, UCSC 46
Activities
5
• What is Decimal 3 in Binary ?
16
RADIX POINT
MANTISSA
EXPONENT
SIGN
0 0 0 1 0
0 X X X 0 0 1 0
0 X X X 0 0 1 0
Unsigned Excess-k
0000.................... 0 -7
0001.................... 1 -6
0010.................... 2 -5
0011.................... 3 k=7 -4
0100.................... 4 -3
0101.................... 5 -2
0110.................... 6 -1
sliding
0111.................... 7 0
ruler 1000.................... 8 1
1001.................... 9 2
1010.................... 10 3
1011.................... 11 4
1100.................... 12 5
1101.................... 13 6
1110.................... 14 7
1111.................... 15 8
© 2020 e-Learning Centre, UCSC 57
Floating Point Example - Exponent
0 X X X 0 0 1 0
0 0 1 1 0 0 1 0
Next, Mantissa…
© 2020 e-Learning Centre, UCSC 61
Floating Point Example 2
1 1 0 1 0
Next, Exponent…
© 2020 e-Learning Centre, UCSC 62
Floating Point Example 2
1 1 0 0 1 0 1 0
5
• Try STORE +2 in 8-bit Floating Point Representation
16
𝟓
+𝟐 = 𝟏𝟎. 𝟎𝟏𝟎𝟏 In Binary
𝟏𝟔
5
• Try STORE +2
16
5
+2 = 10.0101 = 𝟏. 𝟎𝟎𝟏𝟎𝟏 × 𝟐𝟏
16
5
• Try STORE +2
16
5
+2 = 10.0101 = 𝟏. 𝟎𝟎𝟏𝟎𝟏 × 𝟐𝟏
16
0 0 0 1 0 1
5
• Try STORE +2
16
5
+2 = 10.0101 = 𝟏. 𝟎𝟎𝟏𝟎𝟏 × 𝟐𝟏
16
0 0 0 1 0 1
5
• Try STORE +2
16
5
+2 = 10.0101 = 𝟏. 𝟎𝟎𝟏𝟎𝟏 × 𝟐𝟏
16
0 1 0 0 0 0 1 0
5
• Try STORE +2
16
5
+2 = 10.0101 = 𝟏. 𝟎𝟎𝟏𝟎𝟏 × 𝟐𝟏
16
0 1 0 0 0 0 1 0
5
• Original Value = 2
16
• Stored Value = 01000010 = 𝟏. 𝟎𝟎𝟏𝟎 × 𝟐𝟏
= 10.01
1
=2
4
• Therefore, the Rounding Off Error in this case is
5 1
=2 −2
16 4
1
=
16
0 1 1 1 1 1 1 1
= 1.1111 x 24
= 31
0 0 0 0 0 0 0 0
= 0.125
1 0 0 0 0 0 0 0
= - 0.125
1 1 1 1 1 1 1 1
= -1.1111 x 24
= - 31
Range Range
- 31 - 0.125 0.125 + 31
Negative Positive
Overflow Overflow
0
Range Range
- Max - Min + Min + Max
Negative Positive
Underflow Underflow
10
© 2020 e-Learning Centre, UCSC
0