proposal: numeric scale functions

Started by Marko Tiikkajaabout 10 years ago2 messages
#1Marko Tiikkaja
marko@joh.to

Hi,

Dealing with "numeric"s right now in cases where it's really important
that the scale is correct is quite painful. For example, if I want to
accept a EUR amount as an input, I often want to reject values such as
'21.413', but I'd be fine with e.g. '21.410000'. My suggestion is to
add two functions: one to return the number of decimal places in a
numeric, and another one to remove non-significant decimal places.
These two functions are useful on their own, and when combined allow you
to look at the number of significant decimal places in a numeric.

Any thoughts, objections?

.m

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Marko Tiikkaja (#1)
Re: proposal: numeric scale functions

On 11/11/15 5:03 AM, Marko Tiikkaja wrote:

Dealing with "numeric"s right now in cases where it's really important
that the scale is correct is quite painful. For example, if I want to
accept a EUR amount as an input, I often want to reject values such as
'21.413', but I'd be fine with e.g. '21.410000'. My suggestion is to
add two functions: one to return the number of decimal places in a
numeric, and another one to remove non-significant decimal places.

I can see both of these being useful, but the terminology is not
correct. The trailing zeroes are "significant". Maybe the function
could be called "trim", in analogy to trimming whitespace off strings.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers