Floating Point Lab - Tanisha Mittal

pdf

School

Purdue University *

*We aren’t endorsed by this school

Course

176

Subject

Computer Science

Date

Feb 20, 2024

Type

pdf

Pages

4

Uploaded by HighnessPartridge943

Report
CNIT 17600 - Intro Computer Architecture - Floating Point Lab 1 Floating Point Lab Questions Question 1 a. Convert the decimal number 1439878:97234x10 12 to the format SEEMMMM with the exponent stored excess-55. The implied decimal point is to the right of the first mantissa digit. Use the standard 0 for positive numbers and 1 for negative. Note carefully the number of digits in the mantissa. Answer: We increase and decrease the exponent so that we can move the decimal to a feasible place. 143987897234x10 12 = 1.489878 X 10 18 55 + 18 = 73 In SEEMMMM format: 0731439 S 0 EE 73 MMMM 1439 b. What is the smallest number (i.e. closest to zero) you can use with this format before underow occurs? There should be a positive and a negative version of this smallest number. Answer: Smallest Positive Number: 0.0001 10 -55 Smallest Negative Number: - 0.0001 10 -55 c. What is the largest number (i.e. furthest away from zero) you can use with this format before overow occurs? There should be a positive and a negative version of this largest number. Answer: Largest Positive Number: 0.9999 10 54 Smallest Negative Number: -0.9999 10 54
CNIT 17600 - Intro Computer Architecture - Floating Point Lab 1 Question 2 a. Convert the decimal number -0.00000007003755464x10 -21 to the format SEEMMMMMM with the exponent stored excess-25. The implied decimal point is at the start of the mantissa. Use the standard 0 for positive numbers and 1 for negative. Note carefully the number of digits in the mantissa. Answer: In SEEMMMMMM format: 151700375 b. What is the smallest number (i.e. closest to zero) you can use with this format before underow occurs? There should be a positive and a negative version of this smallest number. Answer: Smallest Positive: 0.000007x10 -25 Smallest Negative: -0.000007x10 -25 c. What is the largest number (i.e. furthest away from zero) you can use with this format before overow occurs? There should be a positive and a negative version of this largest number. Answer: Smallest Positive: 0.999999x10 74 Smallest Negative: -0.999999x10 74 Question 3 a. Convert the decimal number 29182818284 to floating point. Use the format SEEMMMMM. All digits are decimal. The exponent is being stored excess-49 (not excess- 50). The implied decimal point is at the beginning of the mantissa. The sign is 0 for a positive number, 1 for a negative number. Note carefully the number of digits in the mantissa. Answer: In SEEMMMMM format: 04929182 b. What is the range of numbers that can be stored in this format? Answer: Range: 0.00001 x 10 -50 < num < 0.99999 x 10 49
CNIT 17600 - Intro Computer Architecture - Floating Point Lab 1 c. What is the floating-point representation for -28182818284? Answer: 14928182 d. What is the floating-point representation for 0.0000029182818284? Answer: 04429182 Question 4 Given the IEEE-754 Single Precision Floating Point number (stored Excess-127) 011111010101011000000000000000002, determine the following: a. The sign of the mantissa Answer: Positive b. The magnitude of the exponent (convert to base 10) Answer: 121 c. The sign of the exponent Answer: Positive Question 5 Given the IEEE-754 Single Precision Floating Point number (stored Excess-127) 101111010101011000000000000000002, determine the following: a. The sign of the mantissa Answer: Negative b. The magnitude of the exponent (convert to base 10) Answer: 120 c. The sign of the exponent Answer: Negative
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
CNIT 17600 - Intro Computer Architecture - Floating Point Lab 1 Question 6 Using an online conversion calculator, and the mantissa values of the IEEE -754 Single Precision Floating Point numbers from Questions 4 & 5. Answer: 1.4206124205e+37 & -0.05224609375 Question 7 IEEE floating point numbers will occasionally yield incorrect math results when used in computer programs. Using your Raspberry Pi, open the interpreter by typing the word python in the command line. You will get a prompt that shows >>>. Start, for example, With >>> 0.1+0.1 Then try something like >>>0.1+0.2 >>>0.1+0.7 >>>0.3+0.6 >>>0.2+0.7 What happened when you tried to sum these pairs of numbers? Summarize these results in a table. Explain why this happened. Use lecture notes and other resources to find the cause of this phenomenon. Extra credit is available if you can find additional examples of this phenomenon in Python on the Raspberry Pi. Answer: Calculation Solution 0.1+0.1 0.2 0.1+0.2 0.300000000000000004 0.1+0.7 0.7999999999999999 0.3+0.6 0.8999999999999999 0.2+0.7 0.8999999999999999 This phenomenon, in my opinion, arises from the fact that Python requires you to indicate whether to round the result up or even how many decimals you need to round to. With the exception of 0.1, which seems to be the only number to work for the equation, I believe this is occurring because the code is either unclear or the values are not what they appear to be.