Professional Documents
Culture Documents
There is no memory space for the decimal point. However computers represent a finite
number of digits. This limitation allows us to evaluate the maximum and minimum possible
numbers that can be represented. These include:
The fixed point number representation assumes that the binary point is fixed at one
position. The binary point is not actually present in the register, but its presence is assumed
based on whether the number which is stored is a fraction or an integer. Thus fixed point
numbers can either be fractional or integer.
2 6
.1875
2 3 R 0
.1875 x 2 = 0.375 0
2 1 R 1
0 R 1
.375 x 2 = 0.75 0
6.1875 = 0110.0011
.5 x 2 = 1.0 1
0 1 1 0 0 0 1 1
8 4 2 1
0 4 2 0 0 0
4 +2+ +
1|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
= 6.1875
0110.0011 = 6.1875
2 3
.1875
2 1 R 1
.1875 x 2 = 0.375 0
2 0 R 1
.375 x 2 = 0.75 0
= 11 .75 x 2 = 1.5 1
3.1875 = 0011.0011
.5 x 2 = 1.0 1
0 0 1 1 0 0 1 1
= 1 1 0 0 1 1 0 0
• Add 1 to the result.
1 1 0 0 1 1 0 0
+ 1
1 1 0 0 1 1 0 1
– 3.1875 = 1100.1101
1 1 0 0 1 1 0 1
-8 4 2 1
0 4 2 0 0 0
-8 + 4 + +
1100.1101 = – 3.1875
The advantage of fixed point notation is simple arithmetic (same as integer arithmetic) and
therefore faster processing. However, a disadvantage is the limited range, as increasing the
number of bits after the binary point for precision decreases the range and vice versa
2|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Fixed point representation allows the computer to hold fractions, but the range of numbers is still
limited. Even using 4 bytes (32 bits) to hold each number, with 8 bits for the fractional part after the
point, the largest number that can be held is just over 8 million.
In decimal, we can show very large numbers in scientific notation. For example
Here 0.12 is called the mantissa (or coefficient) and 13 is called the exponent. The mantissa
holds the digits and the exponent defines where to place the decimal point. In example
above the point is moved 13 places to the right
The same technique can be used for binary numbers. For example, two bytes (16 bits) might
be divided into 10 bits for the mantissa and 6 bits for the exponent.
mantissa exponent
Sign bit
The sign bit (0) tells us that the number is positive. The mantissa represents 0.1101 and the
exponent tells us to move the point 3 places right, so the number becomes 110.1 which
converted to decimal is 6.5
Note: that the point starts off between the sign bit and the first bit of the mantissa.
Place the point between the sign bit and the first digit of the mantissa.
Convert the exponent to its equivalent decimal form (positive or negative)
Move the point right if the exponent is positive, or left if the exponent is negative,
the appropriate number of places.
Convert the resulting binary number to denary.
Example: convert the following floating point binary number to decimal with 10 bit mantissa
and 8 bit exponent:
0 100000000 11111110
0.100000000 11111110
0.1 exponent – 2
0.001
3|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
0 0 0 1
1
0 0 0
= 0.125
Exercise:
Converting a negative binary floating point number to decimal is similar. However you need
to remember that after moving the binary point, with a positive exponent the left-most bit
will have a negative value
Also if the exponent is negative (indicated by a 1 in its leftmost bit) the binary point is
moved left instead of right. You need to fill in with extra 1’s as you shift the binary point to
the left.
Example: convert the following floating point binary number to decimal with 10 bit mantissa
and 8 bit exponent:
1 100000000 11111110
1.100000000 11111110
1.1 exponent – 2
1.111
1 1 1 1
-1
-1
-1 + +
= - 0.125
Exercise:
4|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Place the point between the sign bit and the first digit of the mantissa.
Convert the exponent to its equivalent decimal form (positive or negative)
Shift the point to the right or to the left to achieve a normalised state, add the
number of places moved to the left to the exponent or subtract if the point was
moved to the right.
Convert the back the exponent to binary maintain the number of bits.
Maintain number of bits of the mantissa by adding 0s to the right.
0 000110101 000010
0.000110101 exponent 2
0.110101 exponent 2 - 3
0.110101 exponent - 1
0 110101000 111111 Normalised
1 111100100 000011
1.111100100 exponent 3
1.00100 exponent 3 - 4
1.00100 exponent - 1
1.001000000 111111 Normalised
5|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Exercise:
Example: Normalise the decimal number 3.1875 using 8 bit for the mantissa and 4 bit for
the exponent.
2 3
2 1 R 1 .1875
2 0 R 1
.1875 x 2 = 0.375 0
.375 x 2 = 0.75 0
= 11
.75 x 2 = 1.5 1
3.1875 = 0011.0011
.5 x 2 = 1.0 1
0011.0011 exponent 0
0.110011 exponent 0 + 2
0.110011 exponent 2
6|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Example: Normalise the decimal number -3.1875 using 8 bit for the mantissa and 4 bit for
the exponent.
2 3
2 1 R 1 .1875
2 0 R 1
.1875 x 2 = 0.375 0
.375 x 2 = 0.75 0
= 11
.75 x 2 = 1.5 1
3.1875 = 0011.0011
.5 x 2 = 1.0 1
0 0 1 1 0 0 1 1
= 1 1 0 0 1 1 0 0
• Add 1 to the result.
1 1 0 0 1 1 0 0
+ 1
1 1 0 0 1 1 0 1
1100.1101 exponent 0
1.001101 exponent 0 + 2
1.001101 exponent 2
1 0011010 0010 Normalised
The size of the exponent determines the range of numbers that can be
represented
7|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
8|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Overflow
Occurs when calculations produce results exceeding the capacity of the result.
Example:
16 bit integers can hold numbers in the range -32768 …32767. So what happens when you
add 2000 to 2000
The siteenth bit contains a ’1’ as a result of adding the two numbers. Yet, numbers with a
’1’ in the leading position are interpreted as negative numbers, so instead of ‘4000’ the
result is interpreted as ‘25536’.
Overflow can also occur in the exponent of a floating point number, when the exponent has
become too large to be represented using the given representation for floating-point
numbers (for example 7 bits for 32-bit integers, or exponents larger than 63).
Underflow
A calculation resulting in a number so small that the negative number used for the exponent
is beyond the number of bits used for exponents is called underflow (example 7 bits for 32-
bit integers, or exponents smaller than -64)
9|Page
Alevel ZIMSEC Computer Science Notes Compiled by Engineer Nyamz +265994961051
Overflow
A CPU with a capacity of 8bits has a capacity of up to 11111111 in binary. If one more bit
was added there would be an overflow error
An example of an 8-bit overflow occurs in the binary sum 11111111 + 1 (denary 255 + 1)
The total is a number bigger than 8 digits, and when this happens the CPU drops overflow
digit because the computer cannot store it anywhere, and the computer thinks 255 + 1 = 0
10 | P a g e