mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Add rint() to /port, remove from qnx/.
This commit is contained in:
37
src/port/rint.c
Normal file
37
src/port/rint.c
Normal file
@ -0,0 +1,37 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rint.c
|
||||
* rint() implementation
|
||||
*
|
||||
* Copyright (c) 1999, repas AEG Automation GmbH
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/port/rint.c,v 1.1 2003/05/09 16:26:29 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "c.h"
|
||||
#include <math.h>
|
||||
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user