Re: How to increase precision?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Katka a Daniel Dunajsky <daniel_katka(at)hotmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to increase precision?
Date: 2003-05-02 22:42:46
Message-ID: 20030502153816.U77106-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 2 May 2003, Katka a Daniel Dunajsky wrote:

> 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?

It's doing integer division since both arguments are integers. You'll need
to make one of them something like float, double or numeric.

For example, queries like:

select 5./2;
select 5/cast(2 as float);

etc... don't do integer division because one of
the arguments isn't typed as an integer type.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Crawford 2003-05-02 22:51:53 Re: Best way to delete time stamped data?
Previous Message Katka a Daniel Dunajsky 2003-05-02 22:33:56 Time formating