comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Can compilers do this?
Date: 1996/02/25
Date: 1996-02-25T00:00:00+00:00	[thread overview]
Message-ID: <dewar.825256002@schonberg> (raw)
In-Reply-To: 4gl344$q4j@wdl1.wdl.loral.com

Mark said

"My guess is that on that machine signed zeros exist and that -0.0 < 0.0
and that -0.0 * 0.0 => 0.0, thus the above gives the right answer when
given a -0.0."

Mark, I think your guess is probably right (this was in response to the
strange abs code for testing for zero). But note that if this was Ada
code, then the compiler involved had a serious bug. In both Ada 83 and
Ada 95, minus zero and plus zero must compare equal.

The situation in Ada 83 is that minus zero does not exist in the language
at all. A machine that generates minus zeroes is simply exhibiting a case
where one Ada value can have multiple hardware representations. If this
is the case, the compiler must ensure that these hardware representations
are treated as identical in all contexts where the semantics of the value
is well defined (an exception would be unchecked conversion, where in any
case the result has some implementation dependence).

The situation in Ada 95 is that minus zero is a recognized value, and certain
operations in the language can tell the difference between minus zero and
plus zero (and in fact MUST do so correctly if Signed_Zeroes is true).
However, equality testing is not among these operations, and must work
"correctly", i.e. plus and minus zero must compare equal.

The other guess of course for the original code is that it came out of
uninformed superstition (the same kind of superstition that says never
compare floating-point values for equality), and that the compiler did
things right, but the programmer did not know or believe that this was
the case!





  parent reply	other threads:[~1996-02-25  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-22  0:00 Can compilers do this? BWBurnsed
1996-02-23  0:00 ` Cordes MJ
1996-02-23  0:00 ` Robert Dewar
1996-02-23  0:00 ` Mark A Biggar
1996-02-24  0:00   ` Robert A Duff
1996-02-23  0:00     ` Robert Dewar
1996-02-25  0:00   ` Robert Dewar [this message]
1996-02-23  0:00 ` Robert Dewar
1996-02-23  0:00 ` Stuart Palin
1996-02-26  0:00 ` Robert I. Eachus
1996-02-26  0:00   ` BWBurnsed
  -- strict thread matches above, loose matches on Subject: below --
1996-02-26  0:00 Marin David Condic, 407.796.8997, M/S 731-93
replies disabled

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