From: | cooper(dot)charles(dot)m(at)gmail(dot)com |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #14138: Inconsistent rounding behavior in float4 coercion |
Date: | 2016-05-15 18:37:14 |
Message-ID: | 20160515183714.1449.53603@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 14138
Logged by: Charles
Email address: cooper(dot)charles(dot)m(at)gmail(dot)com
PostgreSQL version: 9.5.3
Operating system: Linux 3.16.0.70-generic
Description:
Based on my reading of the documentation
(http://www.postgresql.org/docs/9.5/static/datatype-numeric.html) float4
only supports up to 6 decimal places of precision (even if the number fits
comfortably in a 4-byte float). This is fine but I am finding it difficult
to predict which way the float will truncate to:
```
elsendb=> select 15422.55 :: float4;
float4
---------
15422.5
(1 row)
elsendb=> select 11143.15 :: float4;
float4
---------
11143.2
(1 row)
```
Regardless of the default rounding mode (up / down / half even /
you-name-it) I would expect these two to round in the same direction -- or
at least the rounding algorithm to be specified and documented.
Platform information:
charles(at)futurelabs:~$ uname -r
3.16.0-70-generic
charles(at)futurelabs:~$ /lib/x86_64-linux-gnu/libc-2.19.so
GNU C Library (Ubuntu EGLIBC 2.19-0ubuntu6.7) stable release version 2.19,
by Roland McGrath et al.
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.8.2.
Compiled on a Linux 3.13.11 system on 2016-02-16.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs>.
Best,
Charles
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-05-15 20:00:12 | Re: BUG #14138: Inconsistent rounding behavior in float4 coercion |
Previous Message | Tom Lane | 2016-05-14 03:01:54 | Re: pg_get_viewdef() drops casts, causing broken definitions |