[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mpf: x * 1.0 != x

From: Kevin Ryde
Subject: Re: mpf: x * 1.0 != x
Date: 17 Jul 2001 09:40:32 +1000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.5

Peter Moulder <address@hidden> writes:
> Actually, gmp is behaving according to specification here; but x*1==x is
> a desirable property, and easy to give (for mpf_mul, but not mpf_mul_ui
> unfortunately), so I'm sending a patch.

Is this a case where prec+1 limbs are being truncated to prec through
such a multiply?  If so then that's within the application requested
precision and is allowed.

I'm afraid I don't think it's useful to worry too much about exact
equality of two float results.  Equality to within the requested
precision, yes, but not to the extra bits gmp sometimes does and
sometimes doesn't calculate.

There's good reasons not to strip those extra bits consistently,
though they do create scope for confusion.  But remember mpf is not a
smooth extension to IEEE 754 (see www.mpfr.org for that sort of

Perhaps the doco on mpf_cmp should note that equality testing is not
recommended, and mpf_eq should be used instead (though that function
is currently a bit broken).

> A real-world situation where the problem arises is in performing a
> "pivot" operation on matrix A at (i,j), to remove all elements from
> column j other than in row i:

I had an idea simple pivoting has big problems with numeric
instability (but I'm not an expert on such things).  If an exact 1.0,
which you know to be exact, occurs with any frequency you might like
to do an mpf_set, or skip some operations altogether.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]