Closed basiliscos closed 6 years ago
Made a couple of optimizations of invert()
.
We should add an assert that your comment
Parameter `exp` must be positive.
is fulfilled. But there is no exp
parameter. Do you mean base
or mod
or both?
I tried changing the sign of mod
but that doesn't have any effect on the tests. And changing the sign of base
doesn't trigger the assert(success >= 0)
but gives a different answer. When does this operation fail, then?
Parameter
exp
must be positive.
Oopps, sorry, please remove that copy-paste line :)
. But there is no exp parameter. Do you mean base or mod or both?
neither. They both should be non-zero, but can be negative, AFAIK.
I tried changing the sign of mod but that doesn't have any effect on the tests. And changing the sign of base doesn't trigger the assert(success >= 0) but gives a different answer. When does this operation fail, then?
Try 15.Z.invert(25.Z)
base
and mod
good namings?base
returns a zero. Is this wrong?Are base and mod good namings?
I think so. It is (symbolicallty) equivalent base.invert(mod) ==base.powm(-1, mod)
.
A zero base returns a zero. Is this wrong?
Well, yes. cz, 0.powm(0, N) != 1
Great, then everything should be commited on master as you wanted.
Thank you! Please, upload the new version to http://code.dlang.org/
I pushed tag v0.1.1 to github. Is that sufficient?
Apparently ;)
Thanks!