From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d8a,c7637cfdf68e766 X-Google-Attributes: gid109d8a,public X-Google-Thread: 107079,c7637cfdf68e766 X-Google-Attributes: gid107079,public X-Google-Thread: 103376,c7637cfdf68e766 X-Google-Attributes: gid103376,public X-Google-Thread: f8362,c7637cfdf68e766 X-Google-Attributes: gidf8362,public X-Google-Thread: f43e6,c7637cfdf68e766 X-Google-Attributes: gidf43e6,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: floating point comparison Date: 1997/08/03 Message-ID: #1/1 X-Deja-AN: 262134749 References: <01bc9dca$762b6000$e1e989cc@gort> <33E261F7.2EFB@mailgw.sanders.lockheed.com> <33E3ED97.4A56@phoenix.net> Organization: New York University Newsgroups: comp.lang.ada,sci.math.num-analysis,comp.software-eng,comp.theory,sci.math Date: 1997-08-03T00:00:00+00:00 List-Id: Lynn says <> Note that such an optimization MUST give EXACTLY the same result as would be obtained at run-time, or the compiler is violating a specific requirement of the IEEE standard. However, in Ada, watch out! The rules for static expressions conflict with this requirement. So be careful using constants in Ada, you may be requiring over-precise evaluation at compile time. But if only variables are involved, an optimizer is being naughty if it violates these rules. Similar optimizations that are verboten are: x := y / constant1; => x := y * (1.0 / constant1); Actually this is an interesting case, the Ada RM allows this transformation if the model interval of the result is the same, but the IEEE standard only permits the optimization if the results are bit for bit identical. GNAT follows the IEEE standard here, or at least intends to, if you find a counterexample, it is a bug, please submit it (we know of no such bugs, and indeed the gcc backend goes out of its way to avoid incorrect optimizations of this type) Robert Dewar Ada Core Technologies