Floating Point Modulo Operation

后端 未结 4 870
梦谈多话
梦谈多话 2020-12-18 18:28

I am trying to implement the range reduction operation for trigonometry. But instead I think it might be better to just perform a modulo pi/2 operation on incoming data. I

4条回答
  •  猫巷女王i
    2020-12-18 18:59

    Maybe I'm missing the point here, but do you have anything against simply using fmod?

    double theta = 10.4;
    const double HALF_PI = 2 * atan(1);
    double result = fmod(theta, HALF_PI);
    

提交回复
热议问题