 class CheckedInt
   getval = (x) -> if x instanceof CheckedInt then x.val else x
 
-  yield  = (x) -> if Math.abs(x) < BASE then new CheckedInt x else new LongInt x
-
   constructor: (@val = 0) ->
 
   neg: -> new CheckedInt -@val

# A general number class, currently supporting integral Javascript numbers,
# arbitrary precision integers and fractions.
#
# Arguments and results of arithmetic operations are coerced to the best


  sgn: -> if @val < 0 then -1 else if @val > 0 then 1 else 0

  sqrt: -> new CheckedInt Math.floor Math.sqrt @val

  cmp: (other) ->
    x = getval other
    if @val < x then -1 else if @val > x then 1 else 0

  plus: (other) -> asNum @val + getval other

  minus: (other) -> asNum @val - getval other

  times: (other) ->
    x = @val * getval other
    if Math.abs(x) < BASE
      new CheckedInt x
    else
      LongInt.fromNative(@val).times other

  div: (other) -> new CheckedInt Math.floor @val / getval other

  mod: (other) -> new CheckedInt @val % getval other

