comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: [Q] Portability of <= and >= with real operands
Date: 1996/11/29
Date: 1996-11-29T00:00:00+00:00	[thread overview]
Message-ID: <dewar.849320173@merv> (raw)
In-Reply-To: 252531213wnr@diphi.demon.co.uk


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.





  reply	other threads:[~1996-11-29  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-29  0:00 [Q] Portability of <= and >= with real operands JP Thornley
1996-11-29  0:00 ` Robert Dewar [this message]
1996-12-03  0:00   ` Keith Thompson
1996-12-03  0:00     ` Robert Dewar
1996-12-03  0:00     ` Thomas Koenig
1996-12-03  0:00     ` Tucker Taft
1996-12-03  0:00       ` Larry Kilgallen
1996-12-03  0:00         ` Robert Dewar
1996-12-04  0:00       ` Keith Thompson
1996-12-01  0:00 ` Tucker Taft
1996-12-02  0:00   ` Norman H. Cohen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox