Re: Numeric Data Type Rounding Up

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Numeric Data Type Rounding Up
Date: 2012-03-07 17:14:22
Message-ID: 9943.1331140462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com> writes:
> I have a table called weight and this table is tracking weight for a
> few people in a fitness program that just started. I created the table
> as described below:

> fitness=# \d weight
> ...
> lbs | numeric(5,0) | not null

> Now when I enter a value in the 'lbs' field / column of '172.80', it
> rounds the value up to '173.00'.

Well, you told it to: (5,0) says five digits before the decimal point
and none after. Perhaps numeric(5,2) is what you were after.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Carlos Mennens 2012-03-07 17:19:00 Re: Numeric Data Type Rounding Up
Previous Message Carlos Mennens 2012-03-07 16:50:32 Numeric Data Type Rounding Up