home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!noc.near.net!inmet!spock!stt
- From: stt@spock.camb.inmet.com (Tucker Taft)
- Subject: Re: Ada Readability, Book Reference
- Message-ID: <1993Jan4.231946.28620@inmet.camb.inmet.com>
- Sender: news@inmet.camb.inmet.com
- Nntp-Posting-Host: spock
- Organization: Intermetrics Inc, Cambridge MA
- References: <1992Dec30.035143.10291@seas.gwu.edu> <1993Jan4.093155.11894@nobeltech.se> <1993Jan4.174424.5699@seas.gwu.edu>
- Date: Mon, 4 Jan 1993 23:19:46 GMT
- Lines: 36
-
- In article <1993Jan4.174424.5699@seas.gwu.edu>
- mfeldman@seas.gwu.edu (Michael Feldman) writes:
-
- >Hmmm. How on earth could 1.0/3.0 be exact? What would the value be?
- >
- >I checked my Annotated LRM (thanks to Karl Nyberg!) and found AI-00209:
- >"An implementation can refuse to evaluate a static universal real expression
- >only if there are insufficient resources to evaluate the expression exactly,
- >e.g., if there is insufficient memory available. Inexact results must not
- >be delivered."
- >
- >This is interesting. I take it, then, that 1.0/3.0 will be flagged by
- >the compiler, because - unless a rational representation is being
- >used, which is always possible, I suppose - there aren't enough bits
- >in a megabyte to evaluate it exactly. Do compilers use rationals
- >for this? I'll be back later, after a test or two of this!
-
- All Ada compilers I know of have "infinite precision" rational
- arithmetic packages for doing static universal real expressions.
- So yes, 1.0/3.0 is computed exactly in the front end of the
- compiler when it is static universal.
-
- Most Ada compilers compute *all* static real
- expressions (even non-universal) to "infinite precision" since
- that is allowed by the accuracy model and is often simpler
- than simulating the target floating-point hardware in a cross-compiler.
-
- The infinite precision rational arithmetic package is one of
- several things that makes an Ada front end a "fun" piece
- of code to write and maintain ;-).
-
- >Mike Feldman
-
- S. Tucker Taft stt@inmet.com
- Intermetrics, Inc.
- Cambridge, MA 02138
-