Xref: utzoo comp.lang.c:10985 comp.lang.fortran:833 Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: C vs. FORTRAN Keywords: C FORTRAN vectorizing supercomputers religion Message-ID: <143@quintus.UUCP> Date: 28 Jun 88 18:44:39 GMT References: <3136@phoenix.Princeton.EDU> <19633@watmath.waterloo.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 17 In article <19633@watmath.waterloo.edu> rwwetmore@watmath.waterloo.edu (Ross Wetmore) writes: > In C exponentiation is not an operator, but rather a function. >I have seen C programs where a for-loop has been used to avoid >doing a pow() function call or because simple integer exponentiation >doesn't really exist. A Fortran programmer doesn't really think >and just uses '**' which usually just gets translated into an >appropriate function call by the compiler. Not to knock either C or Fortran, but this may be a case where C is better to use than Fortran. Just because ** _looks_ like a simple operation (not that different from *) doesn't mean that it isn't a call to a costly function. I have seen published Fortran code where polynomials were evaluated with an O(N * log(N)) algorithm (N being the degree of the polynomial) instead of an O(N) algorithm, presumably because the programmer thought ** must be cheap. If you have a program calculating X**N where N is an integer but is not in the range -2..+3, take a very careful look at your program to see how it can be improved.