On Sat, Oct 03, 2009 at 12:20:57PM +0100, Raymond O'Donnell wrote: > I thought the idea of NUMERIC was that the value was exact, avoiding > rounding problems that you might get with other floating-point types?
Nope, sorry it's still a computer and thus can't represent anything with infinite precision (just numeric fractions in PG's case, let alone irrational numbers). For example: select (numeric '1'/3) * 3; Gives me back 0.99999999999999999999. What NUMERIC datatypes allow you to do however is allow you to specify the precision used in calculations and storage (i.e. as 10 digits, four of those being fractional digits, as above). Thus you've got a chance of putting a bound on the total error that can accumulate during a calculation. For example, you can choose between storing a few more digits in your accounting tables so that when doing aggregations it comes out with the "right" number at the end---i.e. 10 orders of something cost the same as one order of 10 items. Or you set the precision to be coarser and then the values that have been rounded off will match everything else. -- Sam http://samason.me.uk/ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general