In: Computer Science
Sample Problems – Floating Point Notation and Using Registers
For Problems # 1 – 5 Illustrate the value using floating point notation setting the precision of the mantissa to four (4). Truncate values as required.
- 3,567
26,426
.44444
32.0711
.00003
For problems # 6 -10 solve the equations using binary values in signed integer register ‘R’ of size four (4). Check your work to verify if there is an “overflow error”.
2+3=?
2+(-3)=?
7+5=?
-8+(-7)=?
-5+(-3)=?
For problems # 11 -15 determine the decimal value of the values stored in floating-point register ‘F’. Note: The first bit is the “sign bit”, followed by the “characteristic bit” (using the excess 5 methods), then the mantissa.
F: 05258 14. F: 18516
F: 09987 15. F: 11101
F: 02657
1. For Problems # 1 – 5 Illustrate the value using floating point notation setting the precision of the mantissa to four (4). Truncate values as required.
Move the decimal point and update the exponent accordingly. ( if decimal point moved right side then decrease exponent those many positions. if decimal point moved left side then increase the exponent)
-3,567 = -3567. * 100 = -3.567 * 103
26,426 = 26426. * 100 = 2.642 * 103 (after truncating matissa to 4 places)
.44444 = .4444 * 100 = 4.444 * 10-1
32.0711 = 32.0711 *100 = 3.207 * 101
.00003 = 0.00003 * 100 = 3.0 * 10-5
2. For problems # 6 -10 solve the equations using binary values in signed integer register ‘R’ of size four (4). Check your work to verify if there is an “overflow error”.
Lets represent the numbers in signed 2's complement representation (in 4-bits, MSB is sign) and perform the addition (add the numbers including sign bit, disacrd any carry). If the signs of two numbers is same and the sign of the resultant is different then overflow is possible.
2+3= 0 010 + 0 011 = 0 101, no overflow
2+(-3)= 0 010 + 1 101 = 1 111 (this is in signed 2's complement form) = 1 001 (in signed magnitude form), no overflow
7+5= 0 111 + 0 101 = 1 100 , overflow
-8+(-7)= 1 000 + 1 001 = 0 001, overflow
-5+(-3)= 1 011 + 1 101 = 1 000, no overflow.
For problems # 11 -15 determine the decimal value of the values stored in floating-point register ‘F’. Note: The first bit is the “sign bit”, followed by the “characteristic bit” (using the excess 5 methods), then the mantissa.
F: 05258 :
Sign bit = 0 , number is positive
characteristic bit = 5 , to get exponent subtract 5 (as given excess 5 exponent) , which is = 5-5 =0
Hence the number = +0.258*100 = 0.258 (since matissa has decimal point at left)
F: 09987
Sign bit = 0 , number is positive
characteristic bit = 9 , to get exponent subtract 5 (as given excess 5 exponent) , which is = 9-5 =4
Hence the number = +0.987*104 = 9870
F: 02657
Sign bit = 0 , number is positive
characteristic bit = 2 , to get exponent subtract 5 (as given excess 5 exponent) , which is = 2-5 =-3
Hence the number = +0.657*10-3 = 0.000657
F: 18516
Sign bit = 1 , number is negative
characteristic bit = 8 , to get exponent subtract 5 (as given excess 5 exponent) , which is = 8-5 =3
Hence the number = -0.516*103 = -516
F: 11101
Sign bit = 1 , number is negative
characteristic bit = 1 , to get exponent subtract 5 (as given excess 5 exponent) , which is = 1-5 =-4
Hence the number = -0.101*10-4 = -0.0000101