Skip to content

Commit 8283b65

Browse files
committed
Rewrite rint() to enable removal of copyright mention; patch from
Nathan Wagner Function is simpler too.
1 parent f419a82 commit 8283b65

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/port/rint.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
* rint.c
44
* rint() implementation
55
*
6-
* Copyright (c) 1999, repas AEG Automation GmbH
7-
*
8-
*
96
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/port/rint.c,v 1.2 2003/11/29 19:52:13 pgsql Exp $
7+
* $PostgreSQL: pgsql/src/port/rint.c,v 1.3 2010/02/05 03:20:56 momjian Exp $
118
*
129
*-------------------------------------------------------------------------
1310
*/
@@ -18,20 +15,5 @@
1815
double
1916
rint(double x)
2017
{
21-
double f,
22-
n = 0.;
23-
24-
f = modf(x, &n);
25-
26-
if (x > 0.)
27-
{
28-
if (f > .5)
29-
n += 1.;
30-
}
31-
else if (x < 0.)
32-
{
33-
if (f < -.5)
34-
n -= 1.;
35-
}
36-
return n;
18+
return (x > 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
3719
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy