Unclear documentation of to_char() - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Unclear documentation of to_char()
Date
Msg-id Pine.LNX.4.44.0302232038310.1618-100000@peter.localdomain
Whole thread Raw
List pgsql-hackers
The documentation of to_char() is unclear regarding the meaning of the
various formatting patterns for plus and minus signs:

S    negative value with minus sign (uses locale)
MI    minus sign in specified position (if number < 0)
PL    plus sign in specified position (if number > 0)
SG    plus/minus sign in specified position

Here is what happens: (The quotes in the result are not actually part of
the function result.)

to_char(485.8, 'S9999.999')        ' +485.800'
to_char(485.8, 'MI9999.999')        '   485.800'
to_char(485.8, 'PL9999.999')        '+ 485.800'
to_char(485.8, 'SG9999.999')        '+ 485.800'

to_char(-485.8, 'S9999.999')        ' -485.800'
to_char(-485.8, 'MI9999.999')        '- 485.800'
to_char(-485.8, 'PL9999.999')        '  -485.800'
to_char(-485.8, 'SG9999.999')        '- 485.800'

to_char(485.8, '9999.999S')        ' 485.800+'
to_char(485.8, '9999.999PL')        ' 485.800+'
to_char(485.8, '9999.999MI')        '  485.800 '
to_char(485.8, '9999.999SG')        ' 485.800+'

to_char(-485.8, '9999.999S')        ' 485.800-'
to_char(-485.8, '9999.999PL')        ' -485.800 '
to_char(-485.8, '9999.999MI')        ' 485.800-'
to_char(-485.8, '9999.999SG')        ' 485.800-'

The SG seems to work okay, and the S could be considered okay if the
documentation were adjusted, but I suspect there are a few bugs in PL and
MI.

-- 
Peter Eisentraut   peter_e@gmx.net




pgsql-hackers by date:

Previous
From: Rod Taylor
Date:
Subject: Re: locking mechanism
Next
From: "Dave Page"
Date:
Subject: Re: Linking to "current" docs