Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id BD286B5DC13 for ; Tue, 20 Sep 2011 14:17:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 05363-05 for ; Tue, 20 Sep 2011 17:17:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id C7CCDB5DC17 for ; Tue, 20 Sep 2011 14:17:48 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p8KHHluD087196 for ; Tue, 20 Sep 2011 17:17:47 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p8KHHlZU087195; Tue, 20 Sep 2011 17:17:47 GMT (envelope-from www) Date: Tue, 20 Sep 2011 17:17:47 GMT Message-Id: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6217: to_char() gives incorrect output for very small float values From: "Chris Gernon" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201109/119 X-Sequence-Number: 31136 The following bug has been logged online: Bug reference: 6217 Logged by: Chris Gernon Email address: kabigon@gmail.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 ----------------------------------------