定义

fmod

double fmod (double numer     , double denom);
float fmod (float numer      , float denom);
long double fmod (long double numer, long double denom);
double fmod (Type1 numer      , Type2 denom);       // additional overloads

Compute remainder of division
Returns the floating-point remainder of numer/denom (rounded towards zero):

fmod = numer - tquot * denom 

Where tquot is the truncated (i.e., rounded towards zero) result of: numer/denom.

remainder

double remainder (double numer     , double denom);
float remainder (float numer      , float denom);
long double remainder (long double numer, long double denom);
double remainder (Type1 numer      , Type2 denom);       // additional overloads

Compute remainder (IEC 60559)
Returns the floating-point remainder of numer/denom (rounded to nearest):

remainder = numer - rquot * denom 

Where rquot is the result of: numer/denom, rounded toward the nearest integral value (with halfway cases rounded toward the even number).

%

int numer
int denom
numer%denom
取模运算符,是算术运算符的一种。操作数只能是整数。
返回整除后的余数。

联系

1.都是取余运算

未完待续


peixn
78 声望2 粉丝