From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Noah Misch <noah(at)leadboat(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Re: Zero-padding and zero-masking fixes for to_char(float) |
Date: | 2015-04-02 18:14:43 |
Message-ID: | 20150402181443.GD941@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 1, 2015 at 11:48:37AM -0400, Bruce Momjian wrote:
> This should return something like 15555600000000.000... (per Oracle
> output at the URL above, float4 has 6 significant digits on my compiler)
> but I can't seem to figure how to get printf() to round non-fractional
> parts. I am afraid the only solution is to use printf's %e format and
> place the decimal point myself.
Hearing nothing, I went with the %e approach; patch attached. The new
output looks right:
test=> SELECT to_char(float4 '15555555555555.912345678912345678900000000000000000000000',
repeat('9', 50) || '.' || repeat('9', 50));
to_char
--------------------------------------------------------------------------------------------------------
15555600000000.00000000000000000000000000000000000000000000000000
(1 row)
> The fact I still don't have a complete solution suggests this is 9.6
> material but I still want to work on it so it is ready.
I will keep this patch for 9.6 unless I hear otherwise.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
Attachment | Content-Type | Size |
---|---|---|
to_char.diff | text/x-diff | 31.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-04-02 18:20:48 | Re: Something is rotten in the state of Denmark... |
Previous Message | Robert Haas | 2015-04-02 18:07:53 | Re: Abbreviated keys for Numeric |