home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / ada / 3859 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  2.2 KB

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!nobeltech!leeu
  2. From: leeu@nobeltech.se (Leif Euren)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: Ada Readability, Book Reference
  5. Message-ID: <1993Jan4.093155.11894@nobeltech.se>
  6. Date: 4 Jan 93 09:31:55 GMT
  7. References: <9212281507.AA20416@ajpo.sei.cmu.edu> <1992Dec30.035143.10291@seas.gwu.edu>
  8. Organization: NobelTech AB
  9. Lines: 52
  10.  
  11.  
  12.  
  13.  
  14. In article <9212281507.AA20416@ajpo.sei.cmu.edu> SAHARBAUGH@ROO.FIT.EDU writes:
  15. >>I received one request for a pointer to Bryan & Mendal's
  16. >>book so I may as well post it (same amount of keystrokes).
  17. >>
  18. >[stuff deleted]
  19. >>
  20. >>For many examples the book asks, "What will this
  21. >>program print?"  For example 7.3.12 the answer is
  22. >>"The answer to the question is indeterminate."
  23. >>
  24. >>So I ask "Is Ada readable if you can express an indeterminate
  25. >>program using it?".
  26.  
  27. I think the answer should have been "The answer to the question is
  28. compiler dependant.", and therefore: Yes, Ada is readable, although I
  29. can express compiler dependant programs using it.
  30.  
  31. And in article <1992Dec30.035143.10291@seas.gwu.edu> mfeldman@seas.gwu.edu (Michael Feldman) responded:
  32. >The particular example depends on the evaluation order of the sides of
  33. >the expression ... floating-point arithmetic has indeterminate results
  34. >sometimes, so that (A*B)/C may yield a different result than A*(B/C).
  35. >
  36. >In the specific case, (6.0 * 1.0)/3.0 can yield a different result from 
  37. >6.0 * (1.0 / 3.0) because 1.0/3.0 cannot be exactly represented.
  38. >Therefore an expression like
  39. >  6.0 * (1.0 / 3.0) = (6.0 * 1.0) / 3.0
  40. >may not evaluate to True. Traditional floating-point gotcha.
  41.  
  42. Er... This is not a very good example. The constants used are of
  43. universal_real type, and according to LRM 4.10(4) "... if a universal
  44. expression is a static expression, then the evaluation must be exact."
  45.  
  46. But if I write
  47.  
  48.     B := 1.0;
  49.  
  50.     if 6.0 * (B / 3.0) = (6.0 * B) / 3.0 then
  51.  
  52.     else
  53.  
  54.     end if;
  55.  
  56. your arguments hold true.
  57.  __  __ 
  58. |  \   |  All opinions are my own, even if my employer claims otherwise!
  59. |   \  |
  60. |      |    Leif Euren            NobelTech Systems AB
  61. |  \   |    System Manager Rational      S-175 88 JARFALLA
  62. |__ \__|    tel: +46-758-84072        Sweden
  63.