From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Why no 'Floor for fixed point types
Date: Thu, 30 Oct 2003 04:55:02 GMT
Date: 2003-10-30T04:55:02+00:00 [thread overview]
Message-ID: <3FA0999C.7080602@comcast.net> (raw)
In-Reply-To: vq0569pldh9i78@corp.supernews.com
Randy Brukardt wrote:
> Read G.2.3 to see what the RM says about the accuracy of fixed point.
> In particular, read about the 'perfect result set' and the 'close
> result set'. If you care about accuracy, you need to avoid operations
> which only require a result in the 'close result set', because those
> are cases that the compiler is allowed to be inaccurate.
Actually, there are cases that are allowed to use the close result set
that no compiler goes out of their way to get inaccurate results on.
But whether you limit yourself to the perfect result set, or are willing
to accept some well-behaved cases in the close result set. My real
point is that there are some pathological cases which no one cares
about, and I doubt that any compiler does a perfect job of documenting.
But that is fine with me. As I said, if you care, you check and for the
compiler vendors to try and understand what code the compiler will
generate in 2**93 cases (assuming only three 31-bit 'Smalls) is not
something that I would want any compiler vendor to waste time on.
In any case, the wierd/pathological whatever term you want to use cases
are just not that usual. In the usual cases 1.0/fixed_type'Small is an
integer for all three operands and A'Small/(B'Small * C'Small) is an
integer as well.
Of course, I am one of those nasty people who goes around doing things
like measuring angles in microradians--and declaring a fixed point type
with a 'Small to match. Technically, as declared 'Small is a rational
number (2*Pi/1_000_000.0) since Ada.Numerics.Pi is only declared to 50
decimal places...
But since 'Small is static, it is usally easy to see if the compiler did
a good job of eliminating common factors to simplify the job.
Incidently back in Ada 83 days Paul Hilfinger and I went round and
around on when 2*actual precision or 3*actual precision was needed. I
have implementation notes somewhere and Paul actually published a couple
of papers. These are the calculations that the Ada 95 rules allow to be
done using the close result set, and I think you can see that there are
a few (as I said very pathological) cases where getting even close is
difficult.
I even have a program lying around with painful test cases. I never
distributed it, because I was afraid it would end up in the ACVC/ACATS
test. Remember the reason I was interested in these cases were entirely
from a computational perspective. And if I don't care if compilers do
them well, I don't see why anyone else should. (In one case I used two
different power series expansions for Pi that agree to several thousand
decimal places. And yes, they are written as universal integer
expressions, so the compiler has to expand them exactly at compile time.
I always thought it was funny when new computers would be used to
compute a million digits of Pi or so. In Ada those programs are so fast
they start printing the answer immediately. ;-)
--
Robert I. Eachus
"Quality is the Buddha. Quality is scientific reality. Quality is the
goal of Art. It remains to work these concepts into a practical,
down-to-earth context, and for this there is nothing more practical or
down-to-earth than what I have been talking about all along...the repair
of an old motorcycle." -- from Zen and the Art of Motorcycle
Maintenance by Robert Pirsig
next prev parent reply other threads:[~2003-10-30 4:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 20:09 Why no 'Floor for fixed point types Duncan Sands
2003-10-23 22:06 ` Robert I. Eachus
2003-10-24 16:00 ` Stephen Leake
2003-10-24 18:13 ` Duncan Sands
2003-10-23 23:10 ` Martin Dowie
2003-10-24 21:46 ` Nick Roberts
2003-10-25 4:29 ` Robert I. Eachus
2003-10-25 20:42 ` Nick Roberts
2003-10-25 22:40 ` Robert I. Eachus
2003-10-27 18:59 ` Randy Brukardt
2003-10-28 1:19 ` Robert I. Eachus
2003-10-28 18:23 ` Nick Roberts
2003-10-28 18:34 ` Stephane Richard
2003-10-29 19:26 ` Randy Brukardt
2003-10-30 4:55 ` Robert I. Eachus [this message]
2003-10-28 18:10 ` Nick Roberts
2003-10-27 18:49 ` Randy Brukardt
2003-10-28 18:32 ` Nick Roberts
2003-10-29 19:29 ` Randy Brukardt
2003-10-30 23:41 ` Nick Roberts
2003-10-31 22:25 ` Randy Brukardt
2003-11-06 2:41 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox