In the C99 spec it says of remquo:
The remquo functions are intended for implementing argument reductions which can exploit a few low-order bits of the quotient. Note that x may be so large in magnitude relative to y that an exact representation of the quotient is not practical.
What is an "argument reduction" in this context, and what is an example of one that can exploit a few low-order bits of the quotient?
Argument reduction means mapping the argument of a periodic function into the canonical period (for example, (-π,π] or similar). If you used π/2 as the divisor, the low bits of the quotient would be sufficient for determining the right sign/etc. for trig functions.
Unfortunately, however, remquo
is useless for implementing standard trigonometric argument reduction, because π
is irrational; reducing large arguments modulo an approximation of π will give you results with no significant bits, i.e. all error.
If however you're writing a function f(x)
defined as sin(πx) or similar, the period is now exactly representable in floating point, and remquo
can do exactly what you need, whereas calling sin(2*M_PI*x)
directly will give results with no significant bits (i.e. all error) when x
is large.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With