 
     if this.sign != other.sign
       this.plus other.neg()
+    else if (resolve cmp(null, this.digits, other.digits)) < 0
+      new LongInt(sub(other.digits, this.digits), -this.sign)
     else
-      digits = sub(this.digits, other.digits)
-      if digits.last() < 0
-        new LongInt(sub(other.digits, this.digits), -this.sign)
-      else
-        new LongInt(digits, this.sign)
+      new LongInt(sub(this.digits, other.digits), this.sign)
 
   toString: (sep = '') ->
     rev = @digits.reverse().drop_while (d) -> d == 0


a = new LongInt(Stream.fromArray([499, 999, 999, 999]), -1)
b = new LongInt(Stream.fromArray [501])

console.log "a   = #{a.toString('_')}"
console.log "b   = #{b.toString('_')}"
console.log "a+b = #{(a.plus b).toString('_')}"
console.log "a-b = #{(a.minus b).toString('_')}"
console.log "a-a = #{(a.minus a).toString('_')}"
console.log "b-a = #{(b.minus a).toString('_')}"

###


if typeof(require) != 'undefined'
  require.paths.unshift __dirname
  { recur, resolve } = require 'trampoline'
  { List }           = require 'list'
  { Stream }         = require 'stream'
else
  { recur, resolve, List, Stream } = this.pazy


class LongInt
