Skip site navigation (1) Skip section navigation (2)

Re: rounding down a number

From: "Duncan Garland" <duncan(dot)garland(at)ntlworld(dot)com>
To: "Michael" <mmcelarn(at)hotmail(dot)com>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: rounding down a number
Date: 2007-03-31 10:43:43
Message-ID: MBEPKEEDMKGCDODFKLPPIEAEEGAA.duncan.garland@ntlworld.com (view raw or flat)
Thread:
Lists: pgsql-novice
What behaviour are you expecting for negative numbers? This is what my
function does:

SELECT f_round( -100.0 ) FROM team LIMIT 1;
SELECT f_round( -100.1 ) FROM team LIMIT 1;
SELECT f_round( -100.4 ) FROM team LIMIT 1;
SELECT f_round( -100.4999999999 ) FROM team LIMIT 1;
SELECT f_round( -100.5 ) FROM team LIMIT 1;
SELECT f_round( -100.5000000001 ) FROM team LIMIT 1;
SELECT f_round( -100.6 ) FROM team LIMIT 1;
SELECT f_round( -100.9 ) FROM team LIMIT 1;

 f_round
---------
    -100
(1 row)

 f_round
---------
    -100
(1 row)

 f_round
---------
    -100
(1 row)

 f_round
---------
    -100
(1 row)

 f_round
---------
    -101
(1 row)

 f_round
---------
    -101
(1 row)

 f_round
---------
    -101
(1 row)

 f_round
---------
    -101
(1 row)

  -----Original Message-----
  From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Michael
  Sent: 30 March 2007 22:39
  To: pgsql-novice(at)postgresql(dot)org
  Subject: [NOVICE] rounding down a number


  Hi,

  I'm trying to round down any number with a half, but keep the round
function for all other fractions.

  For example





  100.1 becomes 100

  100.4 becomes 100

  100.5 becomes 100 (this one would ordinarily round to 101)

  100.6 becomes 101

  100.9 becomes 101



  Thanks, Mick

In response to

pgsql-novice by date

Next:From: Hannes DorbathDate: 2007-03-31 16:28:28
Subject: Re: Anyone know where I can get an 8.2.3 binary for ubuntu?
Previous:From: Mikko PartioDate: 2007-03-31 10:41:33
Subject: Re: Anyone know where I can get an 8.2.3 binary for ubuntu?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group