   log "(#{a}**3 - 1) / #{a}**2 = #{a3dec.div(a2)} (#{a3dec.mod(a2)})"
   log ""
 
-  b = new LongInt 111111111
+  b = new LongInt 111111112
   c = new LongInt 37
   log "#{b} / #{c} = #{b.div c} (#{b.mod c})"
   log ""

  else
    r

divmod = (r, s) ->
  step = (q, h, t, shift) ->
    n = (h?.last() * if shift then BASE else 1) or 0
    d = s.last() + 1
    f = (Math.floor n / d) or (if cmp(h, s) >= 0 then 1 else 0)
    log "divmod step(#{dump(q)}, #{dump(h)}, #{dump(t)}, #{shift}) -- f = #{f}"
    [q_, h_] = [add(q, new Stream(f)), sub(h, streamTimesDigit(s, f))]

    if f and not shift
      recur -> step(q_, h_, t, shift)
    else if shift
      recur -> step(q_, h_, t, false)
    else if t
      recur -> step(
        new Stream(0, -> q_),
        new Stream(t.first(), -> h_),
        t.rest(),
        h_.last() != 0)
    else
      log "  returning [#{dump(q_)},#{dump(h_)}]"
      [q_, h_]

  m = r.size() - s.size()
  resolve step(null, r.drop(m), r.take(m)?.reverse(), false)


# -- The glorious LongInt class

    else if d == 0
      new LongInt(this.sign * other.sign)
    else
      create(div(this.digits, other.digits), this.sign * other.sign)

  mod: (other) -> this.minus(this.div(other).times(other))

  toString: ->
    zeroes = BASE.toString()[1..]
