Comments on ANSI public Oct 86 Public review draft.

Paul Schauble Schauble at mit-multics.arpa
Mon Mar 9 07:51:56 AEST 1987


This is in response to the comments recently posted by Alan Mycroft. Text
bounded by ====== is his.


===============
   c) page 8, line 41.  "Expressions may be evaluated in greater precision
      than required, provided not precision is lost".  I would think
      that it should not be gained either.  Consider IEEE implementation of
      {  float x,y,z;  z = x*y;   if (z == x*y) ... }.
      I believe that it is unreasonable for the condition to fail, BUT
      the current draft seems to permit it.
===============

Perhaps it seems unreasonable, but there are current machines where
arranging otherwise is awkward and expensive. I have to answer this on
HOneywell hardward every few months.

Honeywell uses a slightly unusual register structure that give a float
or double contained in a register an extra 8 bits precision. This is
lost when the value is stored into memory. The most likely code sequence
generated for this example is

       FLD     X          Get X into register
       FMP     Y          Multiply by Y, giving result in register.
                          Result is *double precision plus extra 8 bits*. 
                          That's right, single*single yields double.
       FST     Z          Store results, truncating to single precision
                          without extra bits.
       FCMP    Z          First of IF statement. Compares truncated value
                          In memory to extra precision value in register.
                          Result is probably not equal.

The only way around this is to have the compiler never generate a
register reuse on a floating point value. This seems a serious
inefficiency.

It seems to me much more in accord with reality to say that == is not
defined for float and double. At least, like it or not, the definition
is machine dependant and compiler dependant. It may seem ureasonable
that (x*y == x*y) should fail, but it can and does on many machines.

    Paul
    Schauble  at boTap co at 1



More information about the Comp.lang.c mailing list