Numerical C

Guy Harris guy at rlgvax.UUCP
Sun Apr 29 02:35:59 AEST 1984


> BTW: What is the origin of the double-precision only nature of C? I've heard
> three differing, but non-conflicting reasons:
> 1.) PDP-11's did all floating point calculations in double (is this true?)
>     anyway, so why not.

It's not true, so this isn't the reason.

> 2.) C was written as a systems language which required little little use of
>     floats, so they were added only as an afterthought.

> 3.) The compilers are much easier to write if one doesn't have to worry
>     about two or more types of float.

I suspect this may have been part of the reason; *on the PDP-11*, it's easier
to write the compiler that way, but not in general.  The reason is that the
PDP-11 floating point instruction set (the *real* floating point instruction
set, not the abortion that came on the 11/35, 11/40, and LSI-11) has two
"mode bits".  There wasn't enough room in the instruction set for an "add
float" and an "add double" instruction, so they had a "set floating" and a
"set double" instruction, and the "add float/add double" instruction was one
or the other depending on the current mode.  Any compiler for the PDP-11 has
to keep track of the mode if it doesn't want to generate a flood of unnecessary
"set floating" or "set double" instructions.  It *can* be done - DEC's Fortran
IV Plus compiler does it, although I think it assumes the mode is unknown
at the entry to a basic block.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list