This is fmod.c in view mode; [Download] [Up]
double fmod(x,y)
double x,y;
{
/*
Routine determines the remainder of x/y with the same sign as x
Routine made by J.A.M. Vermaseren 20-apr-1992
*/
double floor(),z;
if ( y == 0. ) return(x);
if ( y > 0 ) {
if ( x < y && x > -y ) return(x);
}
else if ( x > y && x < -y ) return(x);
z = x/y;
z -= floor(z);
z *= y;
if ( x < 0 ) {
if ( z > 0 ) {
if ( y > 0 ) z = z - y;
else z = z + y;
}
}
else {
if ( z < 0 ) {
if ( y > 0 ) z = z + y;
else z = z - y;
}
}
return(z);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.