Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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


pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group