IEEE-754 Question: Execute the following while loops (modifying the code to add a counter). Explain the reasons these loops for the observed count value.
1 2 3 4 |
c = zeros(3,1); x = 1; while 1 + x > 1, x = x / 2, c(1) = c(1) + 1, end %53 x = 1; while x + x > x, x = 2 * x, c(2) = c(2) + 1, end %1024 x = 1; while x + x > x, x = x / 2, c(3) = c(3) + 1, end %1075 |
Solution The counter is 53, 1024, 1075 for the above three for loops. The code is attatched in 4.2. According to IEEE-754 (double precision), the machine epsilon is $2^{-52}$….