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
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);