pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Juancho <squid@maxiconsumo.com>
To: pgsql-admin@postgresql.org
Subject: Precision when substracting two values with SQL
Date: Mon, 12 Aug 2002 16:57:32 -0300
Message-ID: <3D58132C.6040303@maxiconsumo.com> (raw)

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





view thread (6+ messages)  latest in thread

Message-ID: <3D58132C.6040303@maxiconsumo.com>
Permalink:  ../3D58132C.6040303@maxiconsumo.com/
Also on:    postgresql.org/message-id/3D58132C.6040303@maxiconsumo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: squid@maxiconsumo.com
  Subject: Re: Precision when substracting two values with SQL
  In-Reply-To: <3D58132C.6040303@maxiconsumo.com>
  References: <3D58132C.6040303@maxiconsumo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox