Floating Point Modulo Operation

后端 未结 4 869
梦谈多话
梦谈多话 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

    Exact fmod is implemented with long division. The exact remainder is always representable as the dividend and the divisor share the same format. You can look into open-source implementations like glibc and musl. I have also made one in metallic. (shameless plug)

    Payne–Hanek range reduction is for constant divisors like π, whose reciprocal we store in advance. Hence, it is not applicable here.

提交回复
热议问题