Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: BUG #5150: math bug


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: Robert Haas <robertmhaas(at)gmail(dot)com>
  • Cc: Gray <gray(at)ms-irk(dot)ru>, pgsql-bugs(at)postgresql(dot)org
  • Subject: Re: BUG #5150: math bug
  • Date: Fri, 30 Oct 2009 23:29:29 -0400
  • Message-id: <22942.1256959769@sss.pgh.pa.us> <text/plain>

Robert Haas <robertmhaas(at)gmail(dot)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



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group