Re: Another question about big floating point



On Jun 12, 3:02 am, mike3 <mike4...@xxxxxxxxx> wrote:
Hi.

I've been programming that bignum floating point thing I've talked
about here, and am wondering about this. See, I use the exponent as a
power of 4294967296 (ie. 2^32) instead of 2 so as to eliminate costly
bit shifting. But then we get to the following scenario:

Add (in hex-represented base 4294967296):

FC341204.56700000 x 100000000^0
+ FE901421.30000000 x 100000000^0
= 00000001.FAC42626 x 100000000^1 (rounded)

And bam! We just lose a whole 32-bit dword "digit" from the number's
precision. Does this imply what I think it does -- namely that the
size of the integer part does not contribute reliably to the amount of
preicision a floating point number actually has, only the amount of
digits to the right of the radix point (so the numbers above have
effectively only 32 bits of precision)? I'm just curious -- it doesn't
really add much cost to the addition/subtraction/etc. to use that big
integer digit, unlike what bit shifts would cost (they cost as much as
an entire addition of all the digits of the mantissas together
(yikes!)), anyway, and GMP does this and nobody seems to have
complained.


Quite correct. That "wobbling precision" is one of the major
annoyances of the hex (base 16) float historically used by S/
360..zSeries mainframes, and for exactly the same reason - depending
on the value of the most significant digit, it contains between one
and four bits of precision, so a 32 bit float wobbles between 21 and
24 bits of precision in the mantissa (in your case it's 1-32 bits of
wobble). You need to take special care when writing functions because
the errors are accumulated somewhat irregularly. The bigger problem
in some cases is that it makes floats effectively too small for many
purposes, so you're forced to use doubles.

Probably your best bet is to add an extra word and treat the number as
having the minimum number of bits. Although you'll still get some
problems when you're expecting functions to converge, so some careful
analysis is in order, and you may need an extra term on some
functions.

.



Relevant Pages