       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) ->

      r
  step null, a, b

divmod = (r, s) ->
  scale = Math.floor BASE / (s.last() + 1)
  [r_, s_] = (Sequence.stored seqTimesDigit(x, scale) for x in [r, s])
  [m, d] = [s_.size(), s_.last() + 1]

  step = (q, h, t) ->
