home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3251 < prev    next >
Encoding:
Text File  |  1992-08-27  |  2.2 KB  |  56 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!ungar
  3. From: ungar@leland.Stanford.EDU (Jeffrey Ungar)
  4. Subject: Re: Small Language Wanted
  5. Message-ID: <1992Aug28.063802.17618@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: DSG, Stanford University, CA 94305, USA
  8. References: <9224107.5975@mulga.cs.mu.OZ.AU> <DAVIS.92Aug27211418@pacific.mps.ohio-state.edu> <DAVIS.92Aug28015332@pacific.mps.ohio-state.edu>
  9. Date: Fri, 28 Aug 92 06:38:02 GMT
  10. Lines: 44
  11.  
  12. In article <DAVIS.92Aug28015332@pacific.mps.ohio-state.edu> davis@pacific.mps.ohio-state.edu  (John E. Davis) writes:
  13. >
  14. >In a previous article <DAVIS.92Aug27211418@pacific.mps.ohio-state.edu> I
  15. >presented a C program which demonstrates that simply including math.h into a C
  16. >program does not guarantee that `float y, x = 2.0; int i = 4; y = pow(x,i)'
  17. >will produce the correct value for y as a previous poster suggested:
  18.  
  19.         [deleted]
  20. >
  21. >It has been pointed out to me by several people that this is compiler
  22. >dependent and the a true ansi compliant answer will produce the correct
  23. >answer. This is because instead of a declaration like:
  24. >
  25. >the ANSI declaration would read:
  26. >
  27. >                   extern double pow(double, double);
  28. >
  29. >This has the effect of performing the correct typecasts before calling the
  30. >function `pow'.
  31. >But then this behavior contradicts something else the other poster said:
  32.  
  33.      [compiler could use different methods for different argument
  34.       types, like putting x*x inline for pow(x,2)]
  35.  
  36. >Are there really any existing C compliers out there that perform such
  37. >optimizations?       
  38.  
  39. Yes. The Cray standard C compiler does this (and has "comformant arrays" and
  40. complex data types as well) unless you turn off extensions -- it also
  41. vectorizes all of these functions. The Watcom C compiler does not do this
  42. but can place math functions inline in your code using 80387 instructions
  43. like fsin and fsqrt (but it's up to you to ensure that no exceptions occur).
  44.  
  45. >
  46. >--
  47. >     _____________
  48. >#___/John E. Davis\_________________________________________________________
  49. >#
  50. ># internet: davis@amy.tch.harvard.edu
  51. >#   bitnet: davis@ohstpy
  52. >#   office: 617-735-6746
  53. >#
  54.  
  55. P. Jeffrey Ungar     ungar@Embezzle.stanford.edu
  56.