pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Crawford <scrawford@pinpointresearch.com>
To: Katka a Daniel Dunajsky <daniel_katka@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: How to increase precision?
Date: Fri, 2 May 2003 14:13:31 -0800
Message-ID: <20030502221331.86C2B103C9@polaris.pinpointresearch.com> (raw)
In-Reply-To: <Law12-F72YKpDS7hx2700007b3c@hotmail.com>
References: <Law12-F72YKpDS7hx2700007b3c@hotmail.com>

It's assuming INTs and doing int division. Make one a numeric/real or 
explicitly cast:

steve=# select 5/2;
 ?column? 
----------
        2
(1 row)

steve=# select 5./2;
 ?column? 
----------
      2.5
(1 row)

Cheers,
Steve



On Friday 02 May 2003 2:38 pm, Katka a Daniel Dunajsky wrote:
> Hello all,
>
> this is a newbie question:
>
> How to increase the precision of calculations in posgresql?
>
> When I run this query:
>
> select 5/2;
>
> I get:
>
> ?column?
> --------
>        2
>
> It should be 2.5 shouldn't it?
>
> Thank you for your time.
>
> Daniel
>
>
>
>
>
>
> _________________________________________________________________
> Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster




view thread (4+ messages)  latest in thread

Message-ID: <20030502221331.86C2B103C9@polaris.pinpointresearch.com>
Permalink:  ../20030502221331.86C2B103C9@polaris.pinpointresearch.com/
Also on:    postgresql.org/message-id/20030502221331.86C2B103C9@polaris.pinpointresearch.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: scrawford@pinpointresearch.com, daniel_katka@hotmail.com
  Subject: Re: How to increase precision?
  In-Reply-To: <20030502221331.86C2B103C9@polaris.pinpointresearch.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