D - Floating point precision
- Martin M. Pedersen (30/30) Aug 01 2002 Hi,
- Walter (5/21) Aug 01 2002 You are correct.
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 begin 666 test.d M("!F(#T M*3L-" T*(" ('!R:6YT9B B9FQO870Z("5S7&XB+"!B;V]L,G-T<BAF/3UE M>' H,2DI*3L-"B ("!P<FEN=&8H(F1O=6)L93H )7-<;B(L(&)O;VPR<W1R M*&0]/65X<" Q*2DI.PT*(" ('!R:6YT9B B97AT96YD960Z("5S7&XB+"!B M;V]L,G-T<BAE/3UE>' H,2DI*3L-" T*(" ('!R:6YT9B B9B ]("5'7&XB ;+"!F*3L-" T*(" (')E='5R;B P.PT*?0T* ` end
Aug 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 usingtheattached 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 canbeexpected from a conforming D implementation, warning about such errors. Regards, Martin M. Pedersen
Aug 01 2002