Floating point modulus

Support for floating point modulus has been added to DWScript, it extends the “mod” operator to accept floats.

You can now have scripts with code like

r := a mod PI;

On x86 CPUs, the implementation will use the FPREM CPU instruction, which provides a relatively high precision (much higher than approaches based on Frac), and the performance is also better on average.

Performance is only slightly worse if the dividend is much, much larger than the divisor, but in those case the Frac approaches just spit out meaningless results, as they do not maintain enough precision.

Anecdotally, FPREM’s precision is higher than Wolfram Alpha.