As shown in figure take more than a floating point number, take more than an integer,
But in front of the computer's own operation result of the scientific calculator is and is not quite the same as above,
Mod x y, x as the timing is normal, as well as the code, x is negative, but not the same,
18 mod5=2, seems to be - 18/5=4... 2, the method of program is 18/5=- (3). - 3
Isn't the mod in the calculator for more, there are other mean?
Hope to solve, thank you.
CodePudding user response:
Negative in some differences, the baidu hasCodePudding user response:
Fmod () is used to modulus of floating point Numbers more than (a) and its prototype is:Double fmod (double x);
Set the return value of ret, then x=n * y + ret, where n is an integer, ret and x has the same symbol, and the absolute value of ret less than the absolute value of y, if x=0, so the ret=NaN,
Fmod function calculation x divided by y f float remainder, so x=I * y + f, which is an integer, I f and x has the same symbol, and the absolute value of f is less than the absolute value of y,