转自http://msdn.microsoft.com/zh-cn/library/vstudio/20dckbeh.aspx
1、计算浮点其余部分。
double fmod(
double x,
double y
);
float fmod(
float x,
float y
); // C++ only
long double fmod(
long double x,
long double y
); // C++ only
float fmodf(
float x,
float y
);
2、参数:x, y浮点值。
3、返回值
fmod 返回 x / y浮点其余部分。 如果 y 的值为 0.0, fmod 返回安静 Nan。 有关 Nan 的表示形式的信息。 printf 系列的,请参见 printf。
4、备注
fmod 函数求值浮点其余部分 f=x / y这样 x = i * y + f, i 是整数, f 有符号和 x相同,并且,f 的绝对值与 y的绝对值小于。
C++ 允许重载,因此,您可以调用 fmod重载。 在 c. 程序, fmod 总是采用两个双精度并返回二进制文件。
5、要求
包含头文件math.h或cmath
6、示例
// crt_fmod.c
// This program displays a floating-point remainder.
#include <math.h>
#include <stdio.h>
int main( void )
{
double w = -10.0, x = 3.0, z;
z = fmod( w, x );
printf( "The remainder of %.2f / %.2f is %f\n", w, x, z );
}
余数 -10.00/3.00 为 -1.000000
浙公网安备 33010602011771号