pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Gernon <kabigon@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6217: to_char() gives incorrect output for very small float values
Date: Tue, 20 Sep 2011 17:17:47 GMT
Message-ID: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org> (raw)


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

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



view thread (11+ messages)  latest in thread

Message-ID: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org>
Permalink:  ../201109201717.p8KHHlZU087195@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201109201717.p8KHHlZU087195@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kabigon@gmail.com
  Subject: Re: BUG #6217: to_char() gives incorrect output for very small float values
  In-Reply-To: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org>
  References: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox