This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: floating point war casualty list


Zack Weinberg wrote:

> On Tue, May 28, 2002 at 06:41:01PM -0400, Alan Lehotsky wrote:
> 
>>If I recall correctly, there are TWO (or more) PDP-11 floating point
>>formats.  I think it had something to do with word-order for the
>>double-precision FP, but since it's been close to 25 years since I
>>last did anything with the PDP-11 my memory is somewhat fuzzy.
>>
> 
> As far as I know, there's F (single precision), D and G (two versions
> of double), and H (extended).


Correct.


> 
> I had been under the impression that real.c implemented F and G
> formats, but from what people have been saying, real.c's VAX double is
> D format (which may be wrong - G format is/was more popular), and its
> VAX single is actually IEEE format, which is definitely wrong.



Originally VAXes only implemented F and D format, G came later, as well
as H which was emulated on most machines. Just see the instruction
encodings: G is F with a prefix, same for H and D. And I would not claim
from my experience that G was more popular (I believe that the MicroVAX I
only had F and G but D was added back for MicroVAX 2, there may be a
commercial reason behind that).

I'm currently porting old VAX Fortran code (yes, we are still using 
VAX/VMS here) to more modern machines and I've found quite a few bugs of
double passed to a routine expecting single or even the inverse: because D
is only F with 4 more mantissa bytes appended, the effect is sometimes 
hard to notice. OTOH, when you run the code on a machine with IEEE fp, the
failures are rather spectacular. Also g77 is nice to warn when it find
mismatches between parameters and arguments in the same compilation unit, 
but unfortunately can't do anything for separately compiled files.


> 
> Be nice if we had all four and could switch between D and G at
> runtime, but this is nontrivial to implement.


At runtime, it is impossible I believe, or at least too expensive in terms
of code bloat. DEC compilers have/had a switch to select between the two, 
typically /G_FLOAT or /G_FLOATING and I just checked my C, PASCAL and 
FORTRAN compilers: they all default to D format, so this is IMHO the right
choice for gcc.

	Gabriel.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]