Re: Suppress decimal point like digits in to_char? - Mailing list pgsql-general

From Francisco Olarte
Subject Re: Suppress decimal point like digits in to_char?
Date
Msg-id CA+bJJbyY7NsmLBjqk7YM547TOp9nv6Xxj5+KVwo9d0U6981iBg@mail.gmail.com
Whole thread Raw
In response to Re: Suppress decimal point like digits in to_char?  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-general
HI:

On Mon, Mar 14, 2016 at 8:02 PM, Ken Tanzer <ken.tanzer@gmail.com> wrote:
>> price:
>> ------
>> xx5.45
>> xx1.20
>> xxxx99
>> xx2.40
...
> I appreciate the comment and explanation.  But your example shows numbers where the trailing 0s are not suppressed.

Yeah, my fault, but 5.45, 1.25, 99.00, 2.45 will create a that kind of
alignment which stronly suggest its .99. Of course it's not printed as
such, but visually it can trick you, that's why decimal points are
never supressed anc softwar has options to align coluns to the decimal
point.

> It seems to me that if you're requesting suppression of trailing 0s, then you're accepting that your numbers aren't
goingto align in the first place. And so it's hard for me to see how, for example "99." is ever going to be desirable
outputif suppression is what you're after. 

Never desirable for me, but I never use d9, I always do d0, but you are right.

> And just as context on my end, the times I use to_char are generally to merge numbers into a document or some
fragmentof English text. 

For the grouping ',' I see your point, I normally just use defaut
conversion for these as I dislike the grouping.

As I said, I could see a legitimitate case for Dd similar to the 09
stuff, but having so many replace options ( I think you can even do
<trim(trailing '.' from to_char(number, 'FM9999D99'))>, which is
easier on the eye but fails on locales, as the regexp does ( as a
note, in Spain they are inverted, dot for grouping comma for decimals
) ) I do not think it's a big deal, uglier things are coded by me
continuously nearly via muscle memory.

Francisco Olarte.


pgsql-general by date:

Previous
From: Ken Tanzer
Date:
Subject: Re: Suppress decimal point like digits in to_char?
Next
From: Peter Devoy
Date:
Subject: ON CONFLICT DO NOTHING RETURNING