pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: Andrew Sullivan <andrew@libertyrms.info>
Cc: pgsql-admin@postgresql.org
Subject: Re: Precision when substracting two values with SQL
Date: Mon, 12 Aug 2002 16:51:42 -0400
Message-ID: <3D581FDE.B04D7B83@nsd.ca> (raw)
References: <3D58132C.6040303@maxiconsumo.com>
	<20020812162742.Z17166@mail.libertyrms.com>

I think you meant:

select 0.2:: numeric(12,2) - 0.21::numeric(12,2);

If you are not conviced try:

select (0.2-0.21)::numeric(40,20);


Andrew Sullivan wrote:
> 
> On Mon, Aug 12, 2002 at 04:57:32PM -0300, Juancho wrote:
> >
> > ciudadela=# select 0.2-0.21;
> >        ?column?
> > ----------------------
> >  -0.00999999999999998
> > (1 row)
> >
> >       I was hoping -0.01,
> 
> Try
> 
> select (0.2-0.21)::numeric(12,2);
> 
> A
> 
> --
> ----
> Andrew Sullivan                               87 Mowat Avenue
> Liberty RMS                           Toronto, Ontario Canada
> <andrew@libertyrms.info>                              M6K 3E3
>                                          +1 416 646 3304 x110
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org



view thread (6+ messages)

Message-ID: <3D581FDE.B04D7B83@nsd.ca>
Permalink:  ../3D581FDE.B04D7B83@nsd.ca/
Also on:    postgresql.org/message-id/3D581FDE.B04D7B83@nsd.ca

 · 

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: jllachan@nsd.ca, andrew@libertyrms.info
  Subject: Re: Precision when substracting two values with SQL
  In-Reply-To: <3D581FDE.B04D7B83@nsd.ca>
  References: <3D58132C.6040303@maxiconsumo.com> <20020812162742.Z17166@mail.libertyrms.com> <3D581FDE.B04D7B83@nsd.ca>

* 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