home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / ada / 3876 < prev    next >
Encoding:
Text File  |  1993-01-04  |  2.0 KB  |  49 lines

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