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

berni44 dlang at d-ecke.de
Sun Dec 15 18:22:28 UTC 2019


A few hours ago I closed issue 7006 [1] as a WONTFIX. Now 
timon.gehr at gmx.ch opened it again, without any explanation. As I 
don't wont to start an edit war, I prefere to get some other 
opinions from the community.

It's about the integer overload of pow() in std.math and the 
issue askes for adding support for negative exponents. IMHO there 
are two possibilites and non of them makes sense to me:

a) Result type integral: There is no usecase, because in almost 
all cases the result is a fraction which cannot be expressed as 
an integral type. Even when looking at this as a division with 
reminder, the value would always almost be 0. Again not very 
useful.

b) Result type floating: This would be a breaking change. If the 
user wishes this behaviour he could convert the base to a 
floating type first and then call pow. Additionally it 
occasionally would produce wrong results as I pointed out in my 
closing message.

What do you think about this?

[1] https://issues.dlang.org/show_bug.cgi?id=7006


More information about the Digitalmars-d mailing list