Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7BE944761C0 for ; Mon, 12 Aug 2002 16:16:51 -0400 (EDT) Received: from maxint01.maxiconsumo (unknown [200.26.107.66]) by postgresql.org (Postfix) with ESMTP id 20066476142 for ; Mon, 12 Aug 2002 16:14:08 -0400 (EDT) Received: from maxiconsumo.com (192.168.9.17 [192.168.9.17]) by maxint01.maxiconsumo with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id QY4CWBTM; Mon, 12 Aug 2002 17:10:15 -0300 Message-ID: <3D58132C.6040303@maxiconsumo.com> Date: Mon, 12 Aug 2002 16:57:32 -0300 From: Juancho User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Precision when substracting two values with SQL Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/120 X-Sequence-Number: 5235 Hello: I have a problem substracting two values whith SQL. Please consider this cases... ciudadela=# select 0.2-0.2; ?column? ---------- 0 (1 row) That's OK for me, ciudadela=# select 0.2-0.21; ?column? ---------------------- -0.00999999999999998 (1 row) I was hoping -0.01, ciudadela=# select 0.21-0.22; ?column? ---------- -0.01 (1 row) Again, that's OK for me, My question is why is this behavior taking place (the second case), and how can I avoid it. Any suggestion would be really appreciated. Thanks, Juan Manuel Buenos Aires Argentina