Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve the above problem using MIPS. Here is a sample output: Please enter a floating point number: 4.00 The square root of 4.00 is
Please solve the above problem using MIPS.
Here is a sample output:
Please enter a floating point number: 4.00
The square root of 4.00 is 2.00
Calculate Square Root of a Number of Hand To calculate the square root of a mamber by hand in decimal, perform the following steps: 1. Split the mumber into groups of two digits starting from the decimal point along both direc- tions. Make sure to remember how many groups to the left of the the decimal point. See examples below: 123 1 23 03 20 9 25 30 11 62 66 70 925.3 1162.667 1216.2275 12 16 22 So, suppose we want to calculate the square root of 1078.3, after this step, we get three groups of mumbers, 10 78 30 and there are two groups to the left of the decimal point. Set partial result (result), reference number (ref), and remainder (rea) to O. Now go to step 2 2. Calculate ran = (rem x 100) + where n the unnsed group starting from the left-ainst group. In this case, ren. (0 100) + 10-10. .Calculate ref-2x result. In this case ref- 2 x0-. 4. Find the maximum value of r such that y = ((ref x101+z) xz and y re. In this case, is 3 because ((0 101+3) 3 = 9 and 9 10. Calculate result = (result x 101+z. In this case, result = (0 10) + 3 = 3. Also update the remainder by calculating rem = rem-y. In this case, rem= 10-9 = 1. 5. Start with the left ost, find the maxiutha is less than or equal to the left most group. From our example (1078.3), the left most group is 10, thas -3 since 3 x3-9 but 4 x4 16. Use r which is 3 as our initial partial result (result). Caleulate result x 2 = 3 x 2-6 and use it is our reference mnmber (ref). Subtract the first group by r2 and use it is our initial remainder (ren). In this case rem = 10-32-10-9 = l. 6. Stop if the reamkr (ra) is . Otherwise, go hack to stop 2 s ep going until you reu sstisfied precision See the following table for step by step calculation y=((0 x 10) + 3) x 3=9 10 =((6 10) + 2) x2 = 12S178 result = (re ult x 10) + r 178 54 32 12 -((64 10) + 8) 8-5184 reult-(result x 10)+ 3430 64 130 128 -((G56 10) + 3) resalt 246 00 3 (result x 10)+ 19689 24600 3283 y-{(GSO; 10) + T) 7-458009 491 100 result- (result x 10)+ 91100 32837 (65674 x 10) +4) x 4-2625976 3143100 3141100 328374 Requirements 1. You are not allowed to use any square root instructions 2. You are not allowed to use any flosting-point registers or Boating-point instructions 3. The calculation mast be done in decimal as explained in class and in the earlier section. You are not allowed to se any other algorithms 4. Your program mast read user inpat as a string presentation of a Boating-point amber. No need to check for negative value or invalid inputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started