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

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 (view raw or flat)
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

pgsql-bugs by date

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

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