Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 25304476062 for ; Mon, 12 Aug 2002 16:27:05 -0400 (EDT) Received: from lerlaptop.iadfw.net (lerlaptop.iadfw.net [206.66.13.21]) by postgresql.org (Postfix) with ESMTP id 84EC047603C for ; Mon, 12 Aug 2002 16:27:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by lerlaptop.iadfw.net (8.12.5/8.12.5) with ESMTP id g7CKR1kR002390; Mon, 12 Aug 2002 15:27:01 -0500 (CDT) (envelope-from ler@lerctr.org) Subject: Re: Precision when substracting two values with SQL From: Larry Rosenman To: Tim Ellis Cc: pgsql-admin@postgresql.org In-Reply-To: <20020812132407.41c1b314.Tim.Ellis@gamet.com> References: <3D58132C.6040303@maxiconsumo.com> <20020812132407.41c1b314.Tim.Ellis@gamet.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 12 Aug 2002 15:27:01 -0500 Message-Id: <1029184021.473.35.camel@lerlaptop.iadfw.net> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/122 X-Sequence-Number: 5237 On Mon, 2002-08-12 at 15:24, Tim Ellis wrote: > > ciudadela=# select 0.2-0.2; > > 0 > > ciudadela=# select 0.2-0.21; > > -0.00999999999999998 > > ciudadela=# select 0.21-0.22; > > -0.01 > > I also get this on my Postgres 7.2.1, both Linux and Solaris. You are comparing floats. This is a STANDARD problem with Base 10 Floating point. LER -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749