issue 7006 - std.math.pow (integral, integral) crashes on negative exponents

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue Dec 17 21:15:13 UTC 2019


On Tuesday, 17 December 2019 at 20:43:20 UTC, Timon Gehr wrote:
> pow is unstable at ∞ as much as at 0. It's plain weird to think 
> 0.0 is rounded garbage but 1.0 is not, as 1.0+0.0 = 1.0.

You need to look at this from the standardization POV, for 
instance: what do exisiting machine language instructions 
produce.  There are many angles to this, some implementors will 
use hardware instructions that trap on low accuracy results and 
then switch to a software implementation.

However in practice, inifinity is much less of an issue and 
relatively easy to avoid. And low accuracy around 0.0 that leads 
to instability is much more frequent.

But there are various tricks that can be used to increase 
accuracy. For instance you can convert

a*b*c*…   to log(a)+log(b)+log(c)+…

and so on.


More information about the Digitalmars-d mailing list