     super
 
   exec: (ctx) ->
-    val = @execArgs(ctx)
-    MIN_VALUES[val]
+    arg = @execArgs(ctx)
+    if (not arg?)
+      null
+    else
+      MIN_VALUES[arg]
 
 module.exports.MaxValue = class MaxValue extends Expression
   MAX_VALUES: "Integer" : MathUtil.MAX_INT_VALUE, "Real" :MathUtil. MAX_FLOAT_VALUE, "DateTime" : MathUtil.MAX_DATE_VALUE

    @precision = build json.precision

  exec: (ctx) ->
    num = @execArgs(ctx)
    dec = if @precision? then @precision.exec(ctx) else 0
    Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec)

module.exports.Ln = class Ln extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    Math.log @execArgs(ctx)

module.exports.Exp = class Exp extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    Math.exp @execArgs(ctx)

module.exports.Log = class Log extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    @execArgs(ctx).reduce (x,y) -> Math.log(x)/Math.log(y)

module.exports.Power = class Power extends Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    @execArgs(ctx).reduce (x,y) -> Math.pow(x , y)


module.exports.MinValue = class MinValue extends Expression

    super

  exec: (ctx) ->
    args = @execArgs(ctx)
    if (not args? || args.some (x) -> not x?)
      null
    else
      args?.reduce (x,y) ->
        if x.constructor.name == 'Quantity'
          Quantity.doDivision(x,y)
        else
          x / y

module.exports.TruncatedDivide = class TruncatedDivide extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    args = @execArgs(ctx)
    if (not args? || args.some (x) -> not x?)
      null
    else
      Math.floor( args.reduce (x,y) -> x / y)

module.exports.Modulo = class Modulo extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    args = @execArgs(ctx)
    if (not args? || args.some (x) -> not x?)
      null
    else
      args.reduce (x,y) -> x % y

module.exports.Ceiling = class Ceiling extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    arg = @execArgs(ctx)
    if (not arg?)
      null
    else
      Math.ceil arg

module.exports.Floor = class Floor extends  Expression
  constructor: (json) ->
    super

  exec: (ctx) ->
    arg = @execArgs(ctx)
    if (not arg?)
      null
    else
      Math.floor arg

module.exports.Truncate = class Truncate extends Floor

