From: Tom Lane <tgl@sss.pgh.pa.us>
To: Saurabh Mittal <lattim@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: ROUND function ??
Date: Tue, 09 Oct 2001 00:42:41 -0400
Message-ID: <21186.1002602561@sss.pgh.pa.us> (raw)
In-Reply-To: <OE25NZwwPcMFlF8HGmC0000b0ea@hotmail.com>
References: <OE25NZwwPcMFlF8HGmC0000b0ea@hotmail.com>
"Saurabh Mittal" <lattim@hotmail.com> writes:
> select ROUND(0.5) ; returns 0
> select ROUND(1.5) ; returns 2;
> select ROUND(2.5) ; returns 2;
> select ROUND(3.5) ; returns 4;....so on .=20
> I'm sure you would have figured out what's happening !!! Why ??
Because the IEEE float math standard says so. Round-to-nearest-even
is considered good practice.
> How do I get to approximate any number x.5 as x+1 ??
Try FLOOR(x + 0.5) if you really want the other behavior.
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, lattim@hotmail.com
Subject: Re: ROUND function ??
In-Reply-To: <21186.1002602561@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