Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!usc!ucla-cs!math.ucla.edu!euphemia!pmontgom From: pmontgom@euphemia.math.ucla.edu (Peter Montgomery) Newsgroups: comp.lang.fortran Subject: Re: What is the FORTRAN for ? Keywords: FORTRAN, stupidity Message-ID: <164@kaos.MATH.UCLA.EDU> Date: 26 Jul 90 04:19:26 GMT References: <1990Jul25.174153.16896@ecn.purdue.edu> Sender: news@MATH.UCLA.EDU Organization: UCLA Mathematics Dept. Lines: 39 In article <1990Jul25.174153.16896@ecn.purdue.edu> moshkovi@cn.ecn.purdue.edu writes: >Please, don't consider my question offending, but why the h*** in this world >you people still using FORTRAN, while so many nice C around. > Fortran has a large intrinsic function library. For example, Fortran's MAX and MIN functions can have two or more arguments of one type (integer or real), and most compilers generate inline code for these (evaluating each argument only once). C, Pascal, and Ada all lack these functions. Fortran's exponentiation operator ** allows exponents to be integer or real; many compilers check for the common cases of squaring and cubing. Fortran 77 has INT for converting to integer while rounding towards zero, and NINT for converting while rounding to nearest integer; Fortran 90x adds FLOOR and CEIL for rounding towards -infinity or +infinity. What other common languages support all four rounding modes, and allow you to mix them in one expression, as in i = CEIL(TAN(x)) - NINT(SQRT(y)) ? All of these languages lack adequate multiple precision arithmetic operations. For example, let a, b, c be integers with 0 <= a, b < c <= MAXINT, where MAXINT is the largest integer supported by an implementation. I want to get both the quotient a*b/c and the remainder a*b mod c, even though the intermediate product a*b may overflow. The mathematical definitions of these operations do not depend on the target machine, and the operations are essential when doing modular arithmetic (i.e., arithmetic mod c). Furthermore it is easy to generate code for these (e.g., two instructions plus operand accesses on a VAX or SUN 3, a function call on machines lacking double-length integer multiply and divide instructions). But language designers consistently omit them. -- -------- Peter L. Montgomery pmontgom@MATH.UCLA.EDU Department of Mathematics, UCLA, Los Angeles, CA 90024-1555