X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 32C5A9DC81D for ; Sun, 1 Jan 2006 21:25:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83049-01 for ; Sun, 1 Jan 2006 21:25:53 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id D2ECC9DC81A for ; Sun, 1 Jan 2006 21:25:47 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k021PoZE026698; Sun, 1 Jan 2006 20:25:50 -0500 (EST) To: "George Pavlov" cc: pgsql-sql@postgresql.org Subject: Re: avg() with floating-point types In-reply-to: References: Comments: In-reply-to "George Pavlov" message dated "Sun, 01 Jan 2006 16:40:18 -0800" Date: Sun, 01 Jan 2006 20:25:50 -0500 Message-ID: <26697.1136165150@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.059 required=5 tests=[AWL=0.059] X-Spam-Score: 0.059 X-Spam-Level: X-Archive-Number: 200601/5 X-Sequence-Number: 23794 "George Pavlov" writes: > The datatype of both city.latitude and postal_code.latitude is > number(16,12). > This works, but I would like to understand why there is sometimes a > discrepancy between avg(pc.latitude) and what actually gets inserted > into the city table -- is it the usual floating-point discrepancy or is > there something I can do about it? E.g. after the above update: You're forcing the result of the avg() calculation to be rounded to 12 digits when you store it into city.latitude. Your example simply shows that the avg() calculation is being done to more precision than that. regards, tom lane