       create(div(this.digits__, other.digits__), this.sign() * other.sign())
 
   @operator ['mod', '%'], 2, (other) ->
-    this.minus(this.div(other).times(other))
+    d = this.abs().cmp other.abs()
+    if d < 0
+      this
+    else if d == 0
+      new LongInt(0)
+    else
+      create(mod(this.digits__, other.digits__), this.sign() * other.sign())
 
   @operator ['pow', '**'], 2, (other) ->
     if other.sign() > 0

  create = (digits, sign) ->
    n = new LongInt()
    n.digits__ = Sequence.stored digits
    n.sign__ = sign
    n

  convert = (x) ->

      recur -> step(Sequence.conj(0, -> q),
                    Sequence.conj(t.first(), -> h), t.rest())
    else
      [cleanup(q), h && div(h, Sequence.conj(scale))]

  resolve step(null, null, r_.reverse())

div = (r, s) -> divmod(r, s)[0]

mod = (r, s) -> divmod(r, s)[1]

pow = (r, s) ->
  step = (p, r, s) ->
