Re: BUG #5150: math bug - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5150: math bug
Date
Msg-id 22942.1256959769@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5150: math bug  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: BUG #5150: math bug
List pgsql-bugs
Robert Haas <robertmhaas@gmail.com> writes:
> In general, floating point arithmetic is inaccurate and sucky.  That
> has nothing to do with PostgreSQL; it's just life.

Actually, I think these examples are being done in "numeric" not float8.
Your comment stands though --- 1.0/3.0 does not give the exact rational
number 1/3, but some finite decimal approximation to it, which when
multiplied by 3 will not produce exactly 1.0.

There is special-purpose software out there that can compute exactly
with rational numbers, but you aren't likely to find it embedded in any
general-purpose tools like databases --- the use-case just isn't wide
enough.  One reason why not is that it'll still fall down on irrational
numbers.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Pierre"
Date:
Subject: BUG #5155: Error compiling postgresql-8.5alpha2
Next
From: Tom Lane
Date:
Subject: Re: BUG #5155: Error compiling postgresql-8.5alpha2