"The mathematical concept of arithmetic modulo also works for floating point values, and this is one of the first problems that Donald Knuth discusses in his classic book, The Art of Computer Programming (Volume I). That is, once it was basic knowledge."
The floating point module operator is defined as follows:
m = num - iquot*den ; where iquot = int( num/den )
As indicated, the non-operator of the% operator for floating point numbers seems to be related to standards. CRTL provides "fmod" and, as a rule, the "remainder" to execute% on fp numbers. The difference between the two is how they deal with the intermediate rounding of the quota ’.
'remainder' uses rounding to the nearest, and 'fmod' uses simple truncation.
If you write your own C ++ numeric classes, nothing prevents you from changing the legacy without an operation, including the overloaded% operator.
respectfully
Love Feb 08 '19 at 8:14 2019-02-08 08:14
source share