Exploring Floating Point arithmetic i) Find the smallest integer n so that the f
ID: 3586455 • Letter: E
Question
Exploring Floating Point arithmetic
i) Find the smallest integer n so that the floating point value of 1.0+2.0n is equal to 1.0. (You are encouraged to write a script to do this, rather than simple guess and check). Explain, in terms of the properties of double precision floating point arithmetic, why this occurs.
ii) Find the smallest integer n so that the floating point value of 2.0n + 1.0 is equal to 2n. (You are encouraged to write a script to do this, rather than simple guess and check). Explain, in terms of the properties of double precision floating point arithmetic, why this occurs.
iii) The expressions y1 = and y2 = ( + x) x are the same, however when computed with floating point arithmetic they may differ. Compute the relative error between y1 and y2 when x is a power of ten, for x = 1.0, 1.0 × 101, 1.0 × 102..., 1.0 × 1020. Make a table showing both the absolute and relative errors for these values of x.
Explanation / Answer
import java.util.Scanner; /* * www.instanceofjava.com */ public class PasclasTriangleProgram { public static void main(String args[]){ Scanner in = new Scanner(System.in); System.out.println("Enter number of rows "); int rows= in.nextInt(); for(int i =0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.