fmodf

modf returns 1 as the fractional:

三世轮回 提交于 2019-12-02 11:53:06
问题 I have this static method, it receives a double and "cuts" its fractional tail leaving two digits after the dot. works almost all the time. I have noticed that when it receives 2.3 it turns it to 2.29. This does not happen for 0.3, 1.3, 3.3, 4.3 and 102.3. Code basically multiplies the number by 100 uses modf divides the integer value by 100 and returns it. Here the code catches this one specific number and prints out: static double dRound(double number) { bool c = false; if (number == 2.3) c

modf returns 1 as the fractional:

让人想犯罪 __ 提交于 2019-12-02 07:01:57
I have this static method, it receives a double and "cuts" its fractional tail leaving two digits after the dot. works almost all the time. I have noticed that when it receives 2.3 it turns it to 2.29. This does not happen for 0.3, 1.3, 3.3, 4.3 and 102.3. Code basically multiplies the number by 100 uses modf divides the integer value by 100 and returns it. Here the code catches this one specific number and prints out: static double dRound(double number) { bool c = false; if (number == 2.3) c = true; int factor = pow(10, 2); number *= factor; if (c) { cout << " number *= factor : " << number <