Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Order of evaluation, machine floating point Message-ID: <7779@utzoo.UUCP> Date: Mon, 16-Mar-87 17:20:49 EST Article-I.D.: utzoo.7779 Posted: Mon Mar 16 17:20:49 1987 Date-Received: Mon, 16-Mar-87 17:20:49 EST References: <4775@brl-adm.ARPA> Organization: U of Toronto Zoology Lines: 31 > ... for unknown reasons all floating arithmetic is supposed to occur in > double precision. I realize that K&R said it, but I don't know why... Dennis Ritchie answered this on the net a long time ago: > From decvax!harpo!npoiv!alice!research!dmr Wed Sep 8 23:22:25 1982 > Subject: float/double in C > Newsgroups: net.unix-wizards > > Several people have correctly quoted the manual as calling for evaluation > of expressions on (single-precision) floats in double precision. The > rule was made for 3 reasons. > > 1) To make certain that floating-point function arguments and return values > were always double (thus avoiding multiple library routines and constant > need for casts.) > > 2) Because the PDP-11 makes it horribly difficult to mix modes otherwise > (yes, I admit it). > > 3) Because it is numerically more desirable to evaluate single-precision > expressions in double precision, then truncate the result. > > These are in order of importance... Religious use of X3J11 function prototypes will pretty much solve Dennis's #1 problem, #2 is increasingly a dead issue, and #3 is usually true for the naive but makes the pros very unhappy. -- "We must choose: the stars or Henry Spencer @ U of Toronto Zoology the dust. Which shall it be?" {allegra,ihnp4,decvax,pyramid}!utzoo!henry