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

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

From: Christopher Gernon <kabigon(at)gmail(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6217: to_char() gives incorrect output for very small float values
Date: 2011-09-20 17:49:50
Message-ID: CAKwX5KiRDRkWKwvPq5XQy43_LdF+1CR51vzGy9MmbVikmYORew@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Tue, Sep 20, 2011 at 1:39 PM, Kevin Grittner
<Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> These are approximate data types.  On what basis do you think the
> values returned in your examples are wrong?  The demonstrated

Because PostgreSQL still has access to all the significant digits:

test1=# SELECT f FROM t WHERE id = 1;
        f
-----------------
 5.63219288e-032
(1 row)

Since floats are stored with a significand and an exponent, to_char()
should be able to convert 5.6e-32 to text just as easily as it can
convert 5.6e-3. For some reason, it doesn't.

In response to

Responses

pgsql-bugs by date

Next:From: Kevin GrittnerDate: 2011-09-20 18:29:12
Subject: Re: BUG #6217: to_char() gives incorrect output for very small float values
Previous:From: Tom LaneDate: 2011-09-20 17:49:28
Subject: Re: BUG #6217: to_char() gives incorrect output for very small float values

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