ftp.nice.ch/pub/next/developer/hardware/m68k/SoftwareMathCoprocFor68040.2.0.N.sa.tar.gz#/libjv/fmod.c

This is fmod.c in view mode; [Download] [Up]

double jv_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 jv_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 -= jv_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.