pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: cooper.charles.m@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14138: Inconsistent rounding behavior in float4 coercion
Date: Sun, 15 May 2016 18:37:14 +0000
Message-ID: <20160515183714.1449.53603@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14138
Logged by:          Charles
Email address:      cooper.charles.m@gmail.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@futurelabs:~$ uname -r
3.16.0-70-generic

charles@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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (6+ messages)  latest in thread

Message-ID: <20160515183714.1449.53603@wrigleys.postgresql.org>
Permalink:  ../20160515183714.1449.53603@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20160515183714.1449.53603@wrigleys.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: cooper.charles.m@gmail.com
  Subject: Re: BUG #14138: Inconsistent rounding behavior in float4 coercion
  In-Reply-To: <20160515183714.1449.53603@wrigleys.postgresql.org>
  References: <20160515183714.1449.53603@wrigleys.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