Re: Proposal for resolving casting issues - Mailing list pgsql-hackers

From Ross J. Reedstrom
Subject Re: Proposal for resolving casting issues
Date
Msg-id 20020919153051.GI17402@rice.edu
Whole thread Raw
In response to Re: Proposal for resolving casting issues  ("Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>)
Responses Re: Proposal for resolving casting issues
List pgsql-hackers
On Thu, Sep 19, 2002 at 04:57:30PM +0200, Zeugswetter Andreas SB SD wrote:
> 
> > 
> > > Have you seen my example ? If calculated in float4 the result of
> > > 1.00000000000001*1000.0-1000.0 would be 0.0, no ? 
> > 
> > So?  If you are storing one input as float4, then you cannot rationally
> > say that you know the result to better than 6 digits, because you don't
> > know the input to better than 6 digits.  Claiming that 1000.00000000001
> > is a more accurate answer for the product than 1000.0 is simply wishful
> > thinking on your part: nothing to the right of the sixth digit actually
> > means a darn thing, because you don't know whether the input was really
> > exactly 1000, or should have been perhaps 1000.001.
> 
> I still see 1E-10 as a better answer to above calculation than your 0,
> and my snapshot 9/11 does return that 1E-10.

Well, then you'd be wrong. Numerical analysis says you _can't_ get more
information out than went in to the _least_ precise part of a calculation.
What your suggesting is the equivalent of wanting to put up a shelf, so
you estimate the length of the wall by eyeballing it, then measure the
wood for the shelf with a micrometer, to be sure it fits exactly right.

We teach this in intro science classes all the time: if you calculate with
3.14 as an approximation to pi, you better not report the circumference
of a circle as 2.45678932 cm, I'll take off points!

> 
> I do think I grasp the problem :-)

Hmm, I'm not so sure. ;-)

> 
> I give up now. I voiced my concern, and that is as far as my interest goes on this
> actually. I still think fielding what other db's do in this area would be a good 
> thing before proceeding further.

Ah, sorry to drag this on, then. But this is one of those clear cases
were we must fo the right thing, not follow the crowd. PostgreSQL gets
used by a lot of scientific projects (Have you noticed all the big
bioinformatics databases being mentioned on the lists?). Partly because
we're always underfunded, partly because we're academics who like to
have the code. If we start getting basic maths wrong, that'll be a huge
balck eye for the project.

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm@rice.edu
Executive Director                                  phone: 713-348-6166
Gulf Coast Consortium for Bioinformatics              fax: 713-348-6182
Rice University MS-39
Houston, TX 77005


pgsql-hackers by date:

Previous
From: "Shridhar Daithankar"
Date:
Subject: Re: [GENERAL] killing process question
Next
From: Bruce Momjian
Date:
Subject: Re: The TODO List (Was: Re: Open 7.3 items)