From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Greg Stark <stark(at)mit(dot)edu> |
Cc: | Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Christopher Gernon <kabigon(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #6217: to_char() gives incorrect output for very small float values |
Date: | 2011-09-20 21:57:10 |
Message-ID: | 28405.1316555830@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Greg Stark <stark(at)mit(dot)edu> writes:
> On Tue, Sep 20, 2011 at 8:52 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> However, it would
>> be interesting to know what Oracle etc do with NaN and Infinity,
>> assuming they even support such numbers.
> Note that it looks like NUMBER cannot store either Infinity or NaN.
> They can only occur in BINARY_FLOAT and BINARY_DOUBLE. From the docs:
>> If a BINARY_FLOAT or BINARY_DOUBLE value is converted to CHAR or NCHAR, and the input is either infinity or NaN (not a number), then Oracle always returns the pound signs to replace the value.
> And testing shows:
> SQL> select to_char(cast('NAN' as binary_float), 'FM9999.9999') from dual;
> TO_CHAR(CA
> ----------
> ##########
Hmm, interesting. They replace the whole field with '#', not just the
digit positions? Because that's not what is happening in our code at
the moment, for the one case where we consider this at all:
regression=# select to_char('nan'::float8, '9999.9999EEEE');
to_char
----------------
####.########
(1 row)
The EEEE path seems rather broken in some other ways as well:
regression=# select to_char('43.5'::float8, '9999.9999EEEE');
to_char
-------------
4.3500e+01
(1 row)
Since I did not say FM, why is it suppressing leading spaces here?
I'm starting to think that that code needs a wholesale rewrite
(not but what that's true of just about every part of formatting.c).
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-09-20 23:29:01 | Re: BUG #6216: Calling PQconnectdbParams from C++ with a char** |
Previous Message | Greg Stark | 2011-09-20 21:25:54 | Re: BUG #6217: to_char() gives incorrect output for very small float values |