REAL_64 "~=" and rounding

1 message Options
Embed this post
Permalink
fmsalter

REAL_64 "~=" and rounding

Reply Threaded More More options
Print post
Permalink
The following program produced the output shown below the program!
[Smarteiffel snapshot of Jan 13;  gcc 4.4.0]
============================================
class    TEST
         -- program testing accumulating rounding problems

creation  {}  program

feature  {}

   program
   is
      local  x       : REAL_64;
             delta_x : REAL_64;    -- x increment used for a numerical
solution
      do
         from   delta_x := 0.01;
         until  x > 100
         loop
            if  x ~= x.rounded
             then
               std_output.put_real_format(x, 2);
               std_output.put_new_line;
            end

            x := x + delta_x;
         end
      end

end
=======================================
1.00
2.00
18.00
43.00
72.00
=======================================
I can change this to a program which produces the required results. So
that is not the problem.

Introducing a test like the code for "~=" with differing values for the
exponent of 2, produces a number of sets of output values!

Puzzling!

Regards
Frank Salter