From: Tom Lane <tgl@sss.pgh.pa.us>
To: SZŰCS Gábor <surrano@mailbox.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: numeric and float converts to int differently?
Date: Tue, 28 Oct 2003 11:26:22 -0500
Message-ID: <23857.1067358382@sss.pgh.pa.us> (raw)
In-Reply-To: <072c01c39d65$65f83950$0403a8c0@fejleszt4>
References: <072c01c39d65$65f83950$0403a8c0@fejleszt4>
"=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" <surrano@mailbox.hu> writes:
> QUESTION 1: Is it intentional that converting 0.5 to int4
> - from numeric: rounds *away from* zero
> - from float: rounds *towards* zero (tried float4 and float8 too)?
Numeric currently rounds away from zero. We cannot guarantee to make
it work the same as float, because float's rounding behavior is
platform-dependent. A common but not universal behavior is "round to
nearest even integer". See the recent thread about the round() function
(I forget which list it was in, but it was within the past week).
> QUESTION 2: Is it safe to assume it won't change (haven't changed) in the
> upcoming versions?
Numeric's behavior hasn't changed as of 7.4beta5. I do not have a
crystal ball to predict whether we might change it in the future.
I doubt we will ever try to override the platform behavior for float.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, surrano@mailbox.hu
Subject: Re: numeric and float converts to int differently?
In-Reply-To: <23857.1067358382@sss.pgh.pa.us>
* 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