Re: Precision when substracting two values with SQL

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: Andrew Sullivan <andrew(at)libertyrms(dot)info>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Precision when substracting two values with SQL
Date: 2002-08-12 20:51:42
Message-ID: 3D581FDE.B04D7B83@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)libertyrms(dot)info> M6K 3E3
> +1 416 646 3304 x110
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jie Liang 2002-08-12 21:51:31 Re: problem with select into and timestamp.
Previous Message Juancho 2002-08-12 20:33:00 Re: Precision when substracting two values with SQL