Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E2F45B5DC19 for ; Tue, 20 Sep 2011 16:05:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 95325-09 for ; Tue, 20 Sep 2011 19:05:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6A63AB5DC01 for ; Tue, 20 Sep 2011 16:05:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p8KJ5Jdg012260; Tue, 20 Sep 2011 15:05:19 -0400 (EDT) To: "Kevin Grittner" cc: "Christopher Gernon" , pgsql-bugs@postgresql.org Subject: Re: BUG #6217: to_char() gives incorrect output for very small float values In-reply-to: <4E789528020000250004141A@gw.wicourts.gov> References: <201109201717.p8KHHlZU087195@wwwmaster.postgresql.org> <4E78899D020000250004140B@gw.wicourts.gov> <4E789528020000250004141A@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Tue, 20 Sep 2011 13:29:12 -0500" Date: Tue, 20 Sep 2011 15:05:19 -0400 Message-ID: <12259.1316545519@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/123 X-Sequence-Number: 31140 "Kevin Grittner" writes: > Christopher Gernon wrote: >> 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. > Oh, I see your point now, and I agree with you. > We should probably at least put this on the TODO list, I think. Any > objections? If we're gonna fix it, we should just fix it, I think. I was considering taking a stab at it, but if someone else would like to, that's fine too. One other thing I notice in the same area is that the handling of NaNs and infinities seems a bit incomplete. There's an explicit special case for them in the EEEE-format code path, but not otherwise, and I think that the results you get for other formats will vary depending on what the local implementation of snprintf does. What *should* the output be, if the input is NaN or Inf? regards, tom lane