From: utzoo!decvax!harpo!npoiv!alice!research!dmr
Newsgroups: net.unix-wizards
Title: float/double in C
Article-I.D.: research.295
Posted: Wed Sep  8 23:22:25 1982
Received: Thu Sep  9 05:08:33 1982

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.  Now, the people who actually use C for
numerical work seem to feel that on the VAX, at least, they would gladly
give up reason 3 in favor of increasing the speed of evaluation of expressions
involving single-precision numbers.  I am inclined to look kindly on this
reasoning, providing that the first reason above (which is paramount) is
observed.  That is, if one wants to compile
	double a; float b,c;
	a = b+c;
into
	addf3	b,c,r0
	cvtfd	r0,a
one has committed a very venial sin.  However, the sin would be mortal
if one got the wrong answer from sin(b) where b was declared "float."

The real problem with the VAX compiler that was originally complained
about is that through a bug it had the worst of both worlds.  It did
the arithmetic in single precision and also generated useless conversion
instructions that made the whole calculation slower than if it had been
double in the first place.  I understand that this bug has been fixed
in recent versions.

		Dennis Ritchie

P.S.  I am quite aware that reasons 1,2,3 above can also be adduced
in a discussion of shorts vs. longs.  That is a whole other story.

P.P.S.  The sinning pun above actually was unintended-- I noticed it only
during proofreading.