Quote:
Originally Posted by Duncan C
By definition, remainder is an integer function. The remainder is the integer left over when you divide one integer by another. When you divide floating point numbers, the result is another floating point number.
Floating point remainder does not make any sense.
|
UM....wrong, wrong and wrong. Remainder is definitely NOT an integer by definition, nor is it an integer-only function.
By definition, the remainder of a division operation is the result of subtracting the
integral quotient multiplied by the denominator from the numerator:
as in remainder = numerator - quotient * denominator
The integral quotient (a derived result, not supplied in your formula) is the ONLY number that is always an integer in this basic mathematic formula. When calculating a remainder, the results are ALWAYS an integral quotient and a remainder, which may or may not be an integer, of course.
That is the definition.
It most certainly does not matter if the numerator and/or denominator are integers or not,
except when programming, lol... someone needs to whip out their 5th grade math book.
7twenty7 got it right! Correct code should be
Code:
float remainder = fmod(rate,0.2f);
fmod reference here:
fmod - C++ Reference