summaryrefslogtreecommitdiffstats
path: root/libf2c/libF77/d_mod.c
blob: bbc24ad6547bcc8215a9e8a6de9319ae0fa70594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "f2c.h"

#ifdef IEEE_drem
double drem(double, double);
#else
#undef abs
#include <math.h>
#endif
double d_mod(doublereal *x, doublereal *y)
{
#ifdef IEEE_drem
	double xa, ya, z;
	if ((ya = *y) < 0.)
		ya = -ya;
	z = drem(xa = *x, ya);
	if (xa > 0) {
		if (z < 0)
			z += ya;
		}
	else if (z > 0)
		z -= ya;
	return z;
#else
	double quotient;
	if( (quotient = *x / *y) >= 0)
		quotient = floor(quotient);
	else
		quotient = -floor(-quotient);
	return(*x - (*y) * quotient );
#endif
}
OpenPOWER on IntegriCloud