Newsgroups: comp.arch
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Performance increase - a suggestion
Message-ID: <1988Feb4.153622.12978@utzoo.uucp>
Organization: U of Toronto Zoology
References: <235@unicom.UUCP> <28200089@ccvaxa> <3127@phri.UUCP> <408@micropen>, <3177@lll-winken.llnl.gov>
Date: Thu, 4-Feb-88 15:36:18 EST

> This is the "boondoggle" of the C programming language, which I know and
> love, that arose from its early PDP11+FP11 targets...

Not entirely true.  To be certain of my facts on this, I dug out the article
Dennis Ritchie posted about it some five years ago.  Although he acknowledges
the FP11's contribution, he cites that as reason number two, not reason
number one, for C doing everything in double.  Reason number one was the
problem of getting the types of function arguments and return values correct,
combined with a desire to avoid multiple versions of library functions.  He
repeatedly and clearly states that this was the most important reason for
this design decision.

> ... It is being "fixed", read
> that PATCHED, in the ANSI spec by introducing the new type "long double"
> and or by the use of function prototypes...

Well, no, not quite, it is being fixed -- really fixed -- by allowing the
compiler to do floating-point arithmetic in float, rather than double, if
all operands are float, and by permitting function arguments to be passed
as floats given suitable prototypes.  The problem of multiple library
functions can't be entirely avoided for the speed demons, but function
prototypes should make things manageable for ordinary users.  While some
of the permissiveness in the wording may be regrettable (e.g. it is still
legal to do all arithmetic in double, for backward compatibility), the
overall scheme really is a proper fix, not a "patch".

There is room for debate about whether function prototypes are a Good Thing
overall, but they do go a long way towards cleaning up this problem.

"long double" is being introduced mostly because of a non-trivial number
of machines which also have 128-bit floating point.  It has nothing to do
with the all-arithmetic-in-double issue.
-- 
Those who do not understand Unix are |  Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly.    | {allegra,ihnp4,decvax,utai}!utzoo!henry
