In addition to the default % modulo, the math library of C ++ also has a template function float fmod (float _ x, float _ y), which is used to modulo floating point numbers.
% Can only modulo int
There is also a MODF Function
Float
MODF (float _ x, float * _ iptr)
{Return _ builtin_modff (_ x, _ iptr );}
It can break down floating point numbers into integers and decimals.
Double A = 5;
Double B = 2.2;
// Double C = A % B; // This method can only be used for int
// Double C = MODF (A, & B); // splits floating point number A into an integer part and a decimal part, returns the decimal part, and stores the integer part in the memory specified by B.
Double C1 = fmod (a, B); // calculate the remainder of A/B and return a-n * B, with the same symbol as. N = [A/B] (returns an integer to the left zero ). The remainder is the same as the % operation value of C #.