Re: Numeric Data Type Rounding Up - Mailing list pgsql-novice

From Steve Crawford
Subject Re: Numeric Data Type Rounding Up
Date
Msg-id 4F57988C.1040509@pinpointresearch.com
Whole thread Raw
In response to Numeric Data Type Rounding Up  (Carlos Mennens <carlos.mennens@gmail.com>)
List pgsql-novice
On 03/07/2012 08:50 AM, Carlos Mennens wrote:
> I have a table...
>                                  Table "public.weight"
>   Column |         Type          |                      Modifiers
> --------+-----------------------+-----------------------------------------------------
> ...
>   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'.
You specified a precision of 0. Try 2 (if you really want to track to
the 100th of a pound) or 1 for 1/10 pound. numeric(5,2) will be good up
to 999.99 pounds.

steve=# select 123.45::numeric(5,0);
  numeric
---------
      123

steve=# select 123.45::numeric(5,1);
  numeric
---------
    123.5

steve=# select 123.45::numeric(5,2);
  numeric
---------
   123.45

Cheers,
Steve


pgsql-novice by date:

Previous
From: Carlos Mennens
Date:
Subject: Re: Numeric Data Type Rounding Up
Next
From: Jude Lucien
Date:
Subject: How To Store Large Text Strings