Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / port / rint.c
blob86bfa948906e8127afc5e2a26f605bb777b0505a
1 /*-------------------------------------------------------------------------
3 * rint.c
4 * rint() implementation
6 * Copyright (c) 1999, repas AEG Automation GmbH
9 * IDENTIFICATION
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
15 #include "c.h"
16 #include <math.h>
18 double
19 rint(double x)
21 double f,
22 n = 0.;
24 f = modf(x, &n);
26 if (x > 0.)
28 if (f > .5)
29 n += 1.;
31 else if (x < 0.)
33 if (f < -.5)
34 n -= 1.;
36 return n;