fmod.c

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 30 行

C
30
字号
/*	@(#)fmod.c	1.7	*//*LINTLIBRARY*//* *	fmod(x, y) returns the remainder of x on division by y, *	with the same sign as x, *	except that if |y| << |x|, it returns 0. */#include <math.h>doublefmod(x, y)register double x, y;{	double d; /* can't be in register because of modf() below */	/*	 * The next lines determine if |y| is negligible compared to |x|,	 * without dividing, and without adding values of the same sign.	 */	d = _ABS(x);	if (d - _ABS(y) == d)		return (0.0);#ifndef	pdp11	/* pdp11 "cc" can't handle cast of double to void */	(void)#endif	modf(x/y, &d); /* now it's safe to divide without overflow */	return (x - d * y);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?