comp.lang.ada
 help / color / mirror / Atom feed
From: kst@sd.aonix.com (Keith Thompson)
Subject: Re: Effort to Port TSG to Ada-95 and How Fast it Ran in Gnat
Date: 1997/02/21
Date: 1997-02-21T00:00:00+00:00	[thread overview]
Message-ID: <E5xLBK.n13@thomsoft.com> (raw)
In-Reply-To: dewar.856407400@merv


In <dewar.856407400@merv> dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> Some comments on Michael's porting experience
[...]
> (9) A floating point assertion failed (an impossible error) in which
> a particular number was both > and <= another number at the same time.
> This only happened on the Sparc, not in the same code on a  pc, nor on
> the same code on the Verdix/Sparc Ada-83 compiler. It required an extra
> epsilon comparison to be made instead of using the built-in <= operator.
> 
>    --> If two floating point numbers A and B are both non-model numbers
>        if is perfectly possible for all of
> 
>           A = B
>           A < B
>           A <= B
>           A > B
>           A >= B
> 
>        to be true. Code that assumes otherwise is flawed.

This is possible according to the Ada language definition, but it
seems unlikely to happen in real life.  Typically, Ada floating-point
comparisons are implemented simply by generating the appropriate hardware
compare instructions.  These instructions don't know anything about
Ada's concept of model numbers, they just operate on the bits.

It's possible that one or both operands are NaNs (IEEE Not-a-Number),
special non-numeric floating-point values that can result from operations
like 0.0/0.0.  Try printing the values you're trying to compare.
Note that the compiler's runtime routines may or may not handle NaNs
(the language definition doesn't say much about them), so you may have
to do something like an Unchecked_Conversion to an integer type of the
same size to figure out exactly what the values are.  The SPARC processor
manual specifies the layout of the floating-point types, including the
representation of NaN, Infinity, signed zero, denorms, and so forth.

It may also be that the comparison is being done with values in registers
that are stored with different precision than the values in memory,
though I'm not sure how that would lead to the results you describe.

I'd be interested in seeing a small example of this.

-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
Antimatter is not a condiment.




  parent reply	other threads:[~1997-02-21  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-19  0:00 Effort to Port TSG to Ada-95 and How Fast it Ran in Gnat Michael F Brenner
1997-02-19  0:00 ` Robert Dewar
1997-02-20  0:00   ` Larry Kilgallen
1997-02-21  0:00     ` Robert Dewar
1997-02-21  0:00   ` Keith Thompson [this message]
1997-02-21  0:00     ` Robert Dewar
1997-02-20  0:00 ` Robert Dewar
1997-02-27  0:00   ` Mats Weber
1997-03-01  0:00     ` Robert Dewar
1997-03-03  0:00       ` Elaboration order (was: Effort to Port TSG to Ada-95 and How Fast it Ran in Gnat) Mats Weber
replies disabled

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