BUG #6217: to_char() gives incorrect output for very small float values

From: "Chris Gernon" <kabigon(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6217: to_char() gives incorrect output for very small float values
Date: 2011-09-20 17:17:47
Message-ID: 201109201717.p8KHHlZU087195@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 6217
Logged by: Chris Gernon
Email address: kabigon(at)gmail(dot)com
PostgreSQL version: 9.1.0
Operating system: Windows XP
Description: to_char() gives incorrect output for very small float
values
Details:

The to_char() function gives incorrect output for float values whose decimal
expansion has several digits (more than somewhere around 14-15) after the
decimal point.

To reproduce:

CREATE TABLE t (
id serial,
f double precision,
CONSTRAINT t_pk PRIMARY KEY (id)
);

INSERT INTO t (f) VALUES (0.0000000000000000000000000000000563219288);

----------------------------------------

SELECT to_char(f,
'FM999990.99999999999999999999999999999999999999999999999999') FROM t WHERE
id = 1;

Expected Output:
0.0000000000000000000000000000000563219288

Actual Output:
0.

----------------------------------------

SELECT to_char(f,
'999990.99999999999999999999999999999999999999999999999999') FROM t WHERE id
= 1;

Expected Output:
0.00000000000000000000000000000005632192880000000000

Actual Output:
0.00000000000000

----------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2011-09-20 17:39:57 Re: BUG #6217: to_char() gives incorrect output for very small float values
Previous Message Lionel Elie Mamane 2011-09-20 16:05:55 BUG #6216: Calling PQconnectdbParams from C++ with a char**