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

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!ajpo.sei.cmu.edu!progers
  3. From: progers@ajpo.sei.cmu.edu (Pat Rogers)
  4. Subject: Re: Ada Readability, Book Reference
  5. Message-ID: <1993Jan5.115003.29978@sei.cmu.edu>
  6. Summary: rational arithmetic and universal expressions 
  7. Sender: netnews@sei.cmu.edu (Netnews)
  8. Organization: Ada Joint Program Office
  9. References: <1992Dec30.035143.10291@seas.gwu.edu> <1993Jan4.093155.11894@nobeltech.se> <1993Jan4.174424.5699@seas.gwu.edu>
  10. Date: Tue, 5 Jan 1993 11:50:03 EST
  11. Lines: 52
  12.  
  13. In article <1993Jan4.174424.5699@seas.gwu.edu> mfeldman@seas.gwu.edu (Michael Feldman) writes:
  14. >
  15. >Hmmm. How on earth could 1.0/3.0 be exact? What would the value be?
  16. >
  17. >I checked my Annotated LRM (thanks to Karl Nyberg!) and found AI-00209:
  18. >"An implementation can refuse to evaluate a static universal real expression
  19. >only if there are insufficient resources to evaluate the expression exactly,
  20. >e.g., if there is insufficient memory available. Inexact results must not
  21. >be delivered."
  22. >
  23. >This is interesting. I take it, then, that 1.0/3.0 will be flagged by
  24. >the compiler, because - unless a rational representation is being
  25. >used, which is always possible, I suppose - there aren't enough bits
  26. >in a megabyte to evaluate it exactly. Do compilers use rationals
  27. >for this?  I'll be back later, after a test or two of this!
  28. >
  29. >Mike Feldman
  30. >------------------------------------------------------------------------
  31. >Michael B. Feldman
  32. >co-chair, SIGAda Education Committee
  33. >
  34.  
  35. About seven years ago I saw this program (I think by John Squires) on
  36. info-ada (this is a reconstruction from memory). See how long it takes 
  37. your compiler to give up on it -- use a batch queue if you can, especially 
  38. on a virtual memory machine.  If it does eventually compile, you can just 
  39. add lines until it won't...
  40.  
  41. Pat Rogers
  42. progers@ajpo.sei.cmu.edu
  43.  
  44. -------- cut here --------
  45.  
  46. procedure Killer is
  47.  
  48.   A : constant := 1.0 / 3.0;
  49.  
  50.   B : constant := A * A * A * A * A * A * A * A * A * A * A * A * A;
  51.   C : constant := B * B * B * B * B * B * B * B * B * B * B * B * B;
  52.   D : constant := C * C * C * C * C * C * C * C * C * C * C * C * C;
  53.   E : constant := D * D * D * D * D * D * D * D * D * D * D * D * D;
  54.   F : constant := E * E * E * E * E * E * E * E * E * E * E * E * E;
  55.   G : constant := F * F * F * F * F * F * F * F * F * F * F * F * F;
  56.   H : constant := G * G * G * G * G * G * G * G * G * G * G * G * G;
  57.   I : constant := H * H * H * H * H * H * H * H * H * H * H * H * H;
  58.   J : constant := I * I * I * I * I * I * I * I * I * I * I * I * I;
  59.   K : constant := J * J * J * J * J * J * J * J * J * J * J * J * J;
  60.   L : constant := K * K * K * K * K * K * K * K * K * K * K * K * K;
  61.  
  62. begin
  63.   null;
  64. end Killer;
  65.