Category talk:Wren-long: Difference between revisions

Made modMul, modPow more robust.
(Bug fix.)
(Made modMul, modPow more robust.)
Line 708:
// Returns the current instance multiplied by 'n' modulo 'mod'.
modMul(n, mod) {
if (!(n is ULong)) n = ULong.new(n)
if (!(mod is ULong)) mod = ULong.new(mod)
if (mod.isZero) Fiber.abort("Cannot take modMul with modulus 0.")
var x = ULong.zero
var y = this
Line 1,295 ⟶ 1,298:
 
// Returns the current instance multiplied by 'n' modulo 'mod'.
modMul(n, mod) { Long.sigma_(_sig * n.sign , _mag.modMul(n.abs, mod.abs)) }
 
// Returns the current instance to the power 'exp' modulo 'mod'.
modPow(exp, mod) {
if (!(exp is Long)) exp = Long.new(exp)
if (!(mod is Long)) mod = Long.new(mod)
var mag = _mag.modPow(exp, mod)
var sign
9,476

edits