Skip site navigation (1) Skip section navigation (2)

Re: WIP: to_char, support for EEEE format

From: Brendan Jurd <direvus(at)gmail(dot)com>
To: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: to_char, support for EEEE format
Date: 2009-07-30 16:41:42
Message-ID: 37ed240d0907300941g3ddd5e5am8875f4593e1c02ef@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
2009/7/31 Euler Taveira de Oliveira <euler(at)timbira(dot)com>:
> Brendan Jurd escreveu:
>> Limiting to two exponent digits also has the nice property that the
>> output always matches the length of the format pattern:
>>
>> 9.99EEEE
>> 1.23E+02
>>
> I don't think neglecting to represent a valid number is a "nice property".
> What does the length of format pattern have to do with output format?

Most of the format patterns in to_char() are chosen to match the
length of their expected output.  The output of "DD" is two
characters, "Mon" is three and so on.

That's why the scientific notation pattern is "EEEE" and not just "E".

There're certainly exceptions though.  "SG" is actually output as one
character, and "YYYY" expands to however many digits you happen to
have in your year value.

In fact "YYYY" is probably our closest analogy in to_char() to the
number of digits in the exponent.  In almost all cases, it will come
out as four characters but for extraordinarily large values it will
occupy more characters as necessary.

This breaks fixed-width, but is probably a better outcome than failure
to represent the value.

If we apply the same logic to EEEE then it should expand to admit
whatever exponent was given to it.

Cheers,
BJ

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2009-07-30 16:46:43
Subject: Re: WIP: to_char, support for EEEE format
Previous:From: Pavel StehuleDate: 2009-07-30 16:38:02
Subject: Re: WIP: to_char, support for EEEE format

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group