From: kst@aonix.com (Keith Thompson)
Subject: Re: Floating point problems in GNAT
Date: 1997/02/16
Date: 1997-02-16T00:00:00+00:00 [thread overview]
Message-ID: <E5oBMH.6rA@thomsoft.com> (raw)
In-Reply-To: EACHUS.97Feb14115527@spectre.mitre.org
In <EACHUS.97Feb14115527@spectre.mitre.org> eachus@spectre.mitre.org (Robert I. Eachus) writes:
> Correct in general, but in Ada there all fixed-point operations
> other than division by an Integer and some type conversions are exact.
> (Of course the Ada rules require implicit or explicit conversion the
> results of multiplying or dividing two fixed-point values, now you
> know why.) So catastrophic loss of precision can occur, but most
> fixed-point code can be written to avoid loss of precision entirely.
Yes, that's true. Note, however, that in Ada 95 (unlike Ada 83) the
following is legal:
A : Duration := 1.0;
B : Duration := 3.0;
C : Duration := A / B;
The division operator yields a result of type universal_fixed; the
implicit conversion back to type Duration causes a loss of precision.
As far as the programmer is concerned, this looks like an inexact division
operation on type Duration.
Real arithmetic is tricky.
--
Keith Thompson (The_Other_Keith) kst@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.
next prev parent reply other threads:[~1997-02-16 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-02-12 0:00 Floating point problems in GNAT Wolfgang Lohmann
[not found] ` <E5KKo6.CKH@thomsoft.com>
[not found] ` <EACHUS.97Feb14115527@spectre.mitre.org>
1997-02-16 0:00 ` Keith Thompson [this message]
1997-02-16 0:00 ` Robert Dewar
1997-02-19 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox