Re: Fixing geometic calculation

From: marcin mank <marcin(dot)mank(at)gmail(dot)com>
To: Paul Matthews <plm(at)netspace(dot)net(dot)au>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fixing geometic calculation
Date: 2009-08-09 02:41:38
Message-ID: b1b9fac60908081941u30cdc5b9h23e500386d8f52b2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 8, 2009 at 3:07 AM, Paul Matthews<plm(at)netspace(dot)net(dot)au> wrote:

> IEEE754 does not allow two number X and Y, such that X!=Y and (X-Y)==0.
> And since IEEE754 has been around since the 70's or 80's I think we can
> start relying on its existence and behavior by now.
>

You are correct, I think, though this does not solve the division problem:

$ cat t.c
#include <stdio.h>
int main(){
double a=1.000001e-307, b=1e-307, c=a-b;
printf("a=%le, b=%le, c=%le, c==0:%d, a==b:%d
1/c=%le\n",a,b,c,c==0,a==b,1.0/c);
return 0;
}
$ gcc -Wall -O2 t.c
$ ./a.out
a=1.000001e-307, b=1.000000e-307, c=1.000000e-313, c==0:0, a==b:0 1/c=inf

Greetings
Marcin Mańk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-08-09 03:33:57 Re: join removal
Previous Message Jeff Davis 2009-08-09 02:21:48 Re: Patch for 8.5, transformationHook