0.0.3 Release Notes

In earlier releases, Real.pow(Self, Int) simply called through to libm_pow . This is generally acceptable on platforms with a decent math library, but gets some cases wrong for Float and Double when the exponent is so large that it would be rounded in conversion to Self .

For example, consider Float.pow(-1, 0x1000001) . Since the exponent is odd, the result should be -1 , but when we simply called libm_pow(-1, Float(0x1000001)) , the exponent was rounded to an even number, and the result was 1 .

This behavior is fixed in this release; in particular the parity of integer exponents is always preserved, so that we will not have sign errors like above. There is still additional work to be done on the Real.pow implementations--especially to provide better support for platforms with suspect math libraries--but this is a significant improvement to these operations.

I've also added a basic set of test cases to stress these extreme exponents with x close to 1.0; these are the cases for pow requiring the most internal precision, so they also provide key coverage for future implementation of these operations within Swift-Numerics itself.

13 Likes
Terms of Service

Privacy Policy

Cookie Policy