1
Number Representation
krraju.in
2
Digital Computers and Arithmetic: Historical perspective and von Neumann computers, Fixed and floating-point representation of numbers, Addition and Subtraction, Multiplication and Division algorithms, Floating- point arithmetic
operations.
Unit-1
What you’ll learn
krraju.in
Digital Computers and Numbers
3
Numbers can be represented in multiple number base systems.
krraju.in
Representation of Numbers
4
Fixed-point
Number
Floating point
Unsigned
Signed
Signed-magnitude
Signed-1’s complement
Signed-2’s complement
(14) 0000 1110
(+14) 0000 1110
(-14) 1000 1110
(+14) 0000 1110
(-14) 1111 0001
(+14) 0000 1110
(-14) 1111 0010
±
m
×
2
±
e
Mantissa
Exponent
+
(.1001110)
×
2
+
4
2
01001110
000100
Fraction
Exponent
krraju.in
Fixed-point Representation
5
In integer numbers, radix point is fixed and assumed to be to the right of the rightmost digit.
Advantage
Disadvantage
Fixed-point representation is convenient for representing numbers with bounded orders of magnitude.
krraju.in
Unsigned Numbers
6
The fixed point/ integer numbers are represented in signed and unsigned forms.
Unsigned representation
2
1
4
3
0
+∞
krraju.in
Signed Numbers
7
Signed representation
Positive number: Sign bit is 0 and the magnitude is a positive number
Negative number: Sign bit is 1 and the rest of the number is represented in one of the following
Only one way to represent +ve number and three different ways to represent -ve number
2
1
4
3
-3
-4
-1
-2
0
+∞
-∞
krraju.in
Signed Magnitude Representation
8
krraju.in
One’s Complement Representation
9
krraju.in
Two’s Complement Representation
10
Given the representation for +X, the representation for –X is found by taking the 1s complement of +X and adding 1
+14 = 0 000 1110 (8 bit) and 0 000 0000 0000 1110 (16 bit)
-14 = 1 111 0010 (8 bit) and 1 111 1111 1111 0010 (16 bit)
krraju.in
An 8-Bit Number Representation
11
Number | Representation | Example |
2’s Complement | ||
x = 0 | 0 | 0 (0000 0000) |
0 < x < 127 | x | 77 (0100 1101) |
-128 ≤ x <0 | 256 - |x| | -56 (1100 1000) |
Number | Representation | Example |
Sign-Magnitude | ||
x = 0 | 0 or 128 | 0 (0000 0000) 0 (1000 0000) |
0 < x < 127 | x | 77 (0100 1101) |
-127 ≤ x <0 | 128 + |x| | -56 (1011 1000) |
1’s Complement | ||
x = 0 | 0 or 255 | 0 (0000 0000) 0 (1111 1111) |
0 < x < 127 | x | 77 (0100 1101) |
-127 ≤ x <0 | 255 - |x| | -56 (1100 0111) |
krraju.in
Comparison Complement Systems
12
Operation | 1’s Complement | 2’s Complement | Sign bit of the result | |
| If the carry from the MSB is | Then perform: | Then perform: | |
Add | 0 | (Result is in complement form); complement to convert to sign magnitude form | 1 | |
1 | (Result is in sign magnitude form); add 1 to the LSB of the result | (Result is in sign magnitude form); neglect the carry | 0 | |
Left shift | Copy sign bit into the LSB | Insert 0 into the LSB | Sign bit = MSB of magnitude | |
Right shift | Copy sign bit into the MSB of the magnitude | Sign bit unchanged |
krraju.in
Design considerations
Two’s complement is the most common method of representing signed integers on computers, and more generally, fixed point binary values.
13
Which Representation is Better?
krraju.in
Floating-point Representation
14
Real number representation format that allows a fixed number of digits before and after the binary (decimal) point.
krraju.in
Floating-point Numbers
15
Floating point numbers have a sign, mantissa (m) or significand (S), radix (r) or base (b) and exponent (e)
The floating point representation of a number has two parts
±
m
×
r
±
e
±
S
×
b
±
e
krraju.in
Expressible Numbers
16
Overflow and Underflow happen when a value is out of range. If the value is too big, it is overflow, if the value is too small, it is underflow.
krraju.in
Biased Representation
17
krraju.in
Biased Exponent
18
A constant value (called bias) is added to the true exponent. This allows the exponent to be represented as an unsigned integer.
krraju.in
Implied Base
19
The base is not represented in the format.
By increasing the implied base or the number of bits in the exponent field we can increase the range of numbers that can be represented.
Density of Floating-point numbers
krraju.in
Normalization
20
A number in scientific notation with no leading 0s is called a Normalised Number (e.g., 1.0 × 10-8 or 1.0 × 2-3 , Non normalised form: 10.0 × 10-9)
krraju.in
Normalized Number
21
Floating point numbers are usually normalized. The exponent is adjusted so that leading bit (MSB) of mantissa is 1
±0.1bbb…b×2±e
By increasing the number of bits in the mantissa field we can increase the precision of a number.
krraju.in
Normalization Example: Exponentiation to the base 2
22
Structured Computer Organization by A.S.Tanenbaum, 6th ed. P.677
krraju.in
Normalization Example: Exponentiation to the base 16
23
Structured Computer Organization by A.S.Tanenbaum, 6th ed. P.677
krraju.in
Precision and Range
24
In floating point numbers, the mantissa part of the number represents its magnitude or value. The mantissa, together with the exponent, determines the precision and range.
Sign extension means converting a floating point number from one precision to another precision, while maintaining the same value of the number.
krraju.in
Floating Number Systems
25
| Proposed standard | IBM system 360, 370 | Burroughs B-5500 | Control data 6000, 7000 series |
Bits used | 0-31 | 0-31 | 1-47 | 0-59 |
Radix | 2 | 16 | 8 | 8 |
Radix point | Before the first bit (with assumed 1 to left) | Before the first digit | After the last digit | After the last digit |
Mantissa sign position | 0 | 0 | 1 | 0 |
Value position | 9-31 | 8-31 | 9-47 | 12-59 |
Representation | Sign magnitude, fractional, normalized with most significant bit assumed | Sign magnitude | Sign magnitude | One’s complement of the entire word |
Exponent sign position | - | 1 | 2 | 1 |
Value position | 1-8 | 1-7 | 3-8 | 1-11 |
Representation | Value +127 (a non zero number must have a nonzero representation) | Value + 64 | Sign magnitude | Value +1024 if >=0; value +1023 if <0 |
Range of value | -126 to 127 | -64 to +63 | -63 to +63 | -1023 to +1023 |
(Int. to Computer Architecture by H.S.Stone, 2nd ed. 1988, p.76)
krraju.in
IEEE 754 Standard
26
1985
Leftmost bit is the sign bit for the fraction
Exponent value is
krraju.in
Recap
27
krraju.in
Video Links
28
krraju.in