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

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


On Tuesday, 17 December 2019 at 15:07:40 UTC, Dominikus Dittes 
Scherkl wrote:
> If you look at it from mathematical point of view:
> pow is defined as a mapping
> ℕ × ℕ → ℕ
> but if we extend it to
> ℤ × ℤ → ℤ
> we have undefined points, because 1/n is not in ℤ for all n>1.

Not sure what you mean. You can construct any algebra you want.
D  has "defined" x/y for integer values as:

(x/y)*y = x - x%y

So integer division in D is defined through modulo y.

That holds if x=1 and y=n ?

(In typical math you would only use multiplication and modulo on 
integers and simply not define a division operator.)



More information about the Digitalmars-d mailing list