home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / ada / 3841 < prev    next >
Encoding:
Text File  |  1992-12-30  |  2.1 KB  |  57 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!seas.gwu.edu!mfeldman
  3. From: mfeldman@seas.gwu.edu (Michael Feldman)
  4. Subject: Re: Ada Readability, Book Reference
  5. Message-ID: <1992Dec30.035143.10291@seas.gwu.edu>
  6. Sender: news@seas.gwu.edu
  7. Organization: George Washington University
  8. References: <9212281507.AA20416@ajpo.sei.cmu.edu>
  9. Date: Wed, 30 Dec 1992 03:51:43 GMT
  10. Lines: 45
  11.  
  12. In article <9212281507.AA20416@ajpo.sei.cmu.edu> SAHARBAUGH@ROO.FIT.EDU writes:
  13. >I received one request for a pointer to Bryan & Mendal's
  14. >book so I may as well post it (same amount of keystrokes).
  15. >
  16. [stuff deleted]
  17. >
  18. >For many examples the book asks, "What will this
  19. >program print?"  For example 7.3.12 the answer is
  20. >"The answer to the question is indeterminate."
  21. >
  22. >So I ask "Is Ada readable if you can express an indeterminate
  23. >program using it?".
  24. >
  25. The particular example depends on the evaluation order of the sides
  26. of the expression, but more fundamentally, speaks to the approximations
  27. inherent in floating point. Ada's readability has little to do with it -
  28. it's characteristic of digital computers that floating-point arithmetic
  29. has indeterminate results sometimes, so that (A*B)/C may yield a different 
  30. result than A*(B/C). 
  31.  
  32. In the specific case, (6.0 * 1.0)/3.0 can yield a different result from 
  33. 6.0 * (1.0 / 3.0) because 1.0/3.0 cannot be exactly represented.
  34. Therefore an expression like
  35.   6.0 * (1.0 / 3.0) = (6.0 * 1.0) / 3.0
  36. may not evaluate to True. Traditional floating-point gotcha.
  37.  
  38. You chose an example that doesn't make your point very well, because a
  39. programming language can't fix problems inherent in trying to approximate
  40. the real numbers in a finite number of bits.
  41.  
  42. Mike Feldman
  43. ------------------------------------------------------------------------
  44. Michael B. Feldman
  45. co-chair, SIGAda Education Committee
  46.  
  47. Professor, Dept. of Electrical Engineering and Computer Science
  48. School of Engineering and Applied Science
  49. The George Washington University
  50. Washington, DC 20052 USA
  51. (202) 994-5253 (voice)
  52. (202) 994-5296 (fax)
  53. mfeldman@seas.gwu.edu (Internet)
  54.  
  55. "Americans want the fruits of patience -- and they want them now."
  56. ------------------------------------------------------------------------
  57.