Compiled under Redhat Linux<Right
This commit is contained in:
25
nintf.c
Normal file
25
nintf.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user