[geos-devel] QD (Quad-Double) Approach to Robustness

Mateusz Loskot mateusz at loskot.net
Wed Jun 14 14:37:16 EDT 2006


strk at refractions.net wrote:
> On Wed, Jun 14, 2006 at 08:01:53PM +0200, Mateusz Loskot wrote:
> 
>> Sandro,
>> 
>> Your test case is incorrect. You can't compare float numbers as you
>> are doing it in the assert:
>> 
>> assert(tot_check==tot);
>> 
>> especially if you're working with multiplatform library as GEOS. 
>> You can only test how close are both numbers.
>> 
>> There are many problems. float arithmetic on Intel CPUs deos not
>> follow IEEE 754, different representation of float numbers on
>> varios architectures: FPU calculations are made on 80 bits numbers
>> (ext. double) but SSE2 instructions on 64 bits.
> 
> Ok, but equality is actually used in JTS too. Does Java have an
> automatic approximate equality ?


AFAIK, Java supports something like rational number calculations.
For C++, you have Boost Rational Library:
http://www.boost.org/libs/rational/rational.html

> Beside this, the XML testcase I have attached should then represent a
> valid testcase and should be made to work with the current "sloppy"
> fp condition. Problem is that I suppose JTS won't raise the same 
> problem (having different fp threatment).


AFAIK Java follows IEEE 754 regarding float point numbers.

BTW, I'm not sure about those two statements, as I'm not a Java
programmer at all.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the geos-devel mailing list