Re: About exact results and exact endpoints
Hossam Fahmy wrote:
> On Tue, 2013-02-12 at 21:30 -0800, Richard Fateman wrote:
> > It is amusing to consider that [1/3, 0.1d0] could either be
> > converted, with some loss, to two floats [0.3333...3, 0.1d0]
> > or without loss to two rationals, [1/3, 3602879701896397/2^55]
>
> In fact, 3602879701896397/ 2^55 =
> 0.1000000000000000055511151231257827021181583404541015625
> and not 0.1.
>
> It is impossible to get an exact rational representation of the vast
> majority of decimal fractions using only a power of 2 denominator.
> That is the mathematical reason that lead to the inclusion of decimal
> floating point specification in IEEE 754-2008.
Nick Maclaren then complained about the "mathematical reason", and in
fact Hossam agreed that he could have worded it better.
On the first point, namely Richard Fateman's example. I'm afraid Richard
is correct. The literal 0.1d0 does not denote the fraction 1/10, but the
DOUBLE representation thereof, in the programming languages (Fortran, C)
that he mentioned. Indeed, only a language with first-class interval
support (such as some versions of Fortran) *could* use context to perform
outward rounding on literals -- but I don't know if Fortran does. When
the same value comes in through assignment (x = 0.1d0; yy = [0, x]) this
is not possible anymore (in general), so perhaps the consistent position
is to treat the literal the same way.
This is why explicit interval literal support of some kind is needed,
logically through the text2interval() primitive, which optimization can
then replace with a constructed interval via constant propagation.
On the second point, the justification of decimal floating-point (DFP)
compared to binary (BFP) is indeed legal rather than mathematical, and
the primary advantage of 754-2008 DFP is that it supports efficient
emulation of decimal FIXED-point arithmetic as required in financial
calculations. That's why there is quantum support and cohorts, and
why the always-normalized IEEE 854 failed to gain acceptance.
Michel.
---Sent: 2013-02-13 16:49:47 UTC