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