We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f419a82 commit 8283b65Copy full SHA for 8283b65
src/port/rint.c
@@ -3,11 +3,8 @@
3
* rint.c
4
* rint() implementation
5
*
6
- * Copyright (c) 1999, repas AEG Automation GmbH
7
- *
8
9
* IDENTIFICATION
10
- * $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 $
11
12
*-------------------------------------------------------------------------
13
*/
@@ -18,20 +15,5 @@
18
15
double
19
16
rint(double x)
20
17
{
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;
+ return (x > 0.0) ? floor(x + 0.5) : ceil(x - 0.5);
37
}
0 commit comments