August 01, 2002
Hi,

Reading "Floating Point Intermediate Values" in http://www.digitalmars.com/d/float.html I recalled an error I have seen before in C. In a piece of code like this:

    double d = ...some expression...;
    if ( d == ...same expression... ) {
        ...
    }

the condition was false because 'd'  had less precision than used by the '==' operator. Testing with 'dmd', I experience the same behaviour using the attached test program.

Such problems are hard to track down, because the code looks sensible. I guess it is hard to avoid, but I would like to see it documented what can be expected from a conforming D implementation, warning about such errors.


Regards,
Martin M. Pedersen




August 01, 2002
You are correct.

"Martin M. Pedersen" <mmp@www.moeller-pedersen.dk> wrote in message news:aibmps$2fnm$1@digitaldaemon.com...
> Hi,
>
> Reading "Floating Point Intermediate Values" in http://www.digitalmars.com/d/float.html I recalled an error I have seen before in C. In a piece of code like this:
>
>     double d = ...some expression...;
>     if ( d == ...same expression... ) {
>         ...
>     }
>
> the condition was false because 'd'  had less precision than used by the '==' operator. Testing with 'dmd', I experience the same behaviour using
the
> attached test program.
>
> Such problems are hard to track down, because the code looks sensible. I guess it is hard to avoid, but I would like to see it documented what can
be
> expected from a conforming D implementation, warning about such errors.
>
>
> Regards,
> Martin M. Pedersen
>
>
>
>