On 13/08/12 11:11, Don Clugston wrote:
Exactly. I have come to believe that there are very few algorithms originally
designed for integers, which also work correctly for floating point.

  ////////
    import std.stdio;

    void main()
    {
            real x = 1.0/9.0;

            writefln("x = %.128g", x);
            writefln("9x = %.128g", 9.0*x);
    }
  ////////

... well, that doesn't work, does it? Looks like some sort of cheat in place to make sure that the successive division and multiplication will revert to the original number.

Integer code nearly always assumes things like, x + 1 != x, x == x,
(x + y) - y == x.

There's always good old "if(x==0)" :-)

Reply via email to