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

Re: Float Pt Precision

Uncle George wrote:
> Been trying to determine why the double's between an Intel Box & and
> Alpha box are different on postgresql.
> The algoritms:
> 1a)    t1.q = result.A * pt1.x;
> 1b)   t2.q = pt1.y - t1.q;
> and
> 2)    t3.q = result.C = pt1.y - result.A * pt1.x;
> will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
> but will produce different results in the intel    0x402ec4ec4ec4ec50,
> 0x402ec4ec4ec4ec54

That means the Alpha follows the IEEE rules well compared to
the Intel.

Anyway, never do bit compares with FP results. It's a waste of
your time. Only look at the magnitude of the difference.
In my types of code, I look at how many DB down the difference
is to decide if it's the same answer. Lots of things can
effect how the answer turns out. Order of calculation and
optimizations quite commonly change the answer slightly.
Either you want performance and take a non-bit level identical
answers between machine types, or you end up with poor performing
code that might get the same results if you enforce IEEE 64 bit 

As long as your algorithm is not sensitive to low bit errors
you'll be fine. In other words you don't subtract almost
exactly the same numbers from each other. (finite differences)
If you do, then you need to worry about numerical viscosity
and how the HW rounds it's answers.

Keep in mind, FP representation is an approximation to the mathmetically 
correct answer when the exponent gets larger anyway.


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