26 lines
554 B
C
26 lines
554 B
C
/*----------------------------------------------------------------------
|
|
Some systems, such as linux, miss nintf in the math library. This
|
|
is an implementation.
|
|
|
|
Mark Koennecke, February 2000
|
|
---------------------------------------------------------------------------*/
|
|
|
|
#include <math.h>
|
|
float nintf(float f)
|
|
{
|
|
double ip, rm;
|
|
float fRes;
|
|
|
|
rm = modf(f,&ip);
|
|
if(rm < .0)rm = -rm;
|
|
if(rm > .5)
|
|
{
|
|
if(ip < .0)
|
|
ip -= 1.;
|
|
else
|
|
ip += 1.;
|
|
|
|
}
|
|
return (float) ip;
|
|
}
|