Paul D. Anderson wrote:
Joel C. Salomon Wrote:
Paul D. Anderson wrote:
Multiplying two floats produces a number whose potential precision is the sum
of the operands' precision. We need a method to determine what the precision of
the product should be. Not that it's difficult to come up with an answer -- but
we have to agree on something.
Not more precision than the input data deserve. The decimal
floating-point numbers of the new IEEE 754-2008 carry with them a notion
of “how precise is this result?�; this might be a good starting point
for discussion.
—Joel Salomon
The implementation will comply with IEEE 754-2008. I just wanted to illustrate
that precision can depend on the operation as well as the operands.
Paul
I'm not sure why you think there needs to be a precision depending on
the operation.
The IEEE 754-2008 has the notion of "Widento" precision, but AFAIK it's
primarily to support x87 -- it's pretty clear that the normal mode of
operation is to use the precision which is the maximum precision of the
operands. Even when there is a Widento mode, it's only provided for the
non-storage formats (Ie, 80-bit reals only).
I think it should operate the way int and long does:
typeof(x*y) is x if x.mant_dig >= y.mant_dig, else y.
What you might perhaps do is have a global setting for adjusting the
default size of a newly constructed variable. But it would only affect
constructors, not temporaries inside expressions.