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: 103376,338371dbbe7075d X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: [Q] Portability of <= and >= with real operands Date: 1996/11/29 Message-ID: #1/1 X-Deja-AN: 201498927 references: <252531213wnr@diphi.demon.co.uk> organization: New York University newsgroups: comp.lang.ada Date: 1996-11-29T00:00:00+00:00 List-Id: Phil Thornley says "Section 5.5.6 - "... the use of <= is more portable than either < or =" Section 7.2.7 (in the Chapter on Portability) - "Strict relational comparisons (<, >, =, /=) are a general problem with computations involving real numbers" and there is an implication (but no direct statement) that the inclusive comparisons are not a problem. (The Ada 83 version did have a statement that <= and >= evaluated the same in all implementations but this has gone from the Ada 95 version.) Clearly = and /= are to be avoided, but I can't see why < and > are less portable than <= and >=." Anmd wonders about the above quotes from AQ&S. To me they are plain incorrect, as is Phil's conclusion, there is nothing inherently wrong with using exact comparison on floating-point numbers. The rule is like using any operator in any situation, you use it only if careful analysis of your algorithm shows that it has the right semantics for the operatoin you wish to perform. The idea that equality testing on fpt numbers is always wrong is a myth borne of unfamiliarity with floating-point semantics that refuses to die! The idea that the use of <= is more portable than either < or = is particular rubbish, I see no possible justification for such a statement, and, unlike the old rule about avoiding equality, I cannot even guess the thought behind this misunderstanding.