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

Timon Gehr timon.gehr at
Wed Dec 18 04:23:14 UTC 2019

On 18.12.19 01:37, Timon Gehr wrote:
>> According to the standard x^y  is defined as:
>> exp(y * log(x))
>> ...
> Well, that's pretty lazy. Also, it can't be true simultaneously with 
> your claim that pow(0.0,0.0) can be modified to return _anything_, as it 
> would then need to be consistent with exp(0.0*log(0.0)).

I guess what's going on is that exp and log in your expression as it 
occurs in the standard are the actual mathematical functions and `pow` 
is defined to approximate this exact result for arguments where it is 
defined, while for other arguments there is an explicit definition.

Another thing I noticed is that says:
"except where specified above, if any argument is NaN, NaN is returned"

As pow(NaN,0.0) is not "specified above", this seems to say that 
pow(0.0/0.0,0.0) should be NaN. However, g++ gives me 1.

I'm not sure what's going on here. I guess either the documentation is 
wrong or g++ violates the C++ standard in order to satisfy 
recommendations in IEEE 754-2008.

More information about the Digitalmars-d mailing list