Re: Real type with zero - Mailing list pgsql-general

From David Johnston
Subject Re: Real type with zero
Date
Msg-id 008c01cc3674$480cb3c0$d8261b40$@yahoo.com
Whole thread Raw
In response to Re: Real type with zero  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Responses Re: Real type with zero
Re: Real type with zero
List pgsql-general
-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Grzegorz Jaskiewicz
Sent: Wednesday, June 29, 2011 7:44 AM
To: condor@stz-bg.com
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Real type with zero

what you probably looking for is formatting the output into a string.
Postgresql will store it as 2.3, because that is what 2.30 is anyway.
Its up to you to format it before passing it on to the user/business logic/whatever.



I presume (and even if not) the OP is looking to keep the known precision of the value.  If I look at 2.3 I do not know
whetherI have precision of measurement only to the tenths or whether I had higher precision but all positions beyond
thetenths are zero. 

Aside from storing the "true" precision in a separate integer field what solution is there is this situation.  I guess
defining"numeric(S,P)" works although I haven't done much actual work with "precision" in the database and so I do not
knowwhether it is truly sufficient.  I would guess not since there may be cases where the known precision is less than
thedefined precision and so the numeric(S,P) data type will over specify the precision in those cases. 

This is beginning to sound like a varchar(n) versus text argument...

David J.



pgsql-general by date:

Previous
From: "Jonathan S. Katz"
Date:
Subject: Re: point types in "DISTINCT" queries
Next
From: Jeff Davis
Date:
Subject: Re: point types in "DISTINCT" queries