Math library

In a math library, it is frequently useful to use type punning to interpret a floating-point number as an unsigned integer of the same size.

The goal here is to reduce the domain of the argument for the polynomial to process, using the function's symmetry and periodicity (if any), setting flags to indicate e.g. whether to negate the result in the end (if needed).

It is worth noting that periodic functions require higher-than-input precision when reducing, with the prototypical method being the Payne–Hanek–Corbett algorithm.

[6] After range reduction, near-zero values may be subject to a "fast path": for example, a tiny input x can be returned directly in sin, while 1 − |x| may be used for cos.

[7] Finally, the any-base exponent function pow() is built around exp() and log() in the general case.