diff options
author | Bruce Momjian <bruce@momjian.us> | 2010-02-05 03:20:56 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2010-02-05 03:20:56 +0000 |
commit | 8283b65019b6d0274853128d6a618b36745d7e5e (patch) | |
tree | 21932e529d334b559a914ffb01e2a36b38d5f2d9 | |
parent | f419a82c704ec33fe5b861f914935b233a54bcee (diff) | |
download | postgresql-8283b65019b6d0274853128d6a618b36745d7e5e.tar.gz postgresql-8283b65019b6d0274853128d6a618b36745d7e5e.zip |
Rewrite rint() to enable removal of copyright mention; patch from
Nathan Wagner
Function is simpler too.
-rw-r--r-- | src/port/rint.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/port/rint.c b/src/port/rint.c index 860c7b1617c..ff5aab087a0 100644 --- a/src/port/rint.c +++ b/src/port/rint.c @@ -3,11 +3,8 @@ * rint.c * rint() implementation * - * Copyright (c) 1999, repas AEG Automation GmbH - * - * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/rint.c,v 1.2 2003/11/29 19:52:13 pgsql Exp $ + * $PostgreSQL: pgsql/src/port/rint.c,v 1.3 2010/02/05 03:20:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,20 +15,5 @@ double rint(double x) { - double f, - n = 0.; - - f = modf(x, &n); - - if (x > 0.) - { - if (f > .5) - n += 1.; - } - else if (x < 0.) - { - if (f < -.5) - n -= 1.; - } - return n; + return (x > 0.0) ? floor(x + 0.5) : ceil(x - 0.5); } |