From e30e81c0994f31701be56d124ab3cef150e51129 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 20 Sep 2017 05:04:31 +0000 Subject: a few more number functions git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1118 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/expr/DefaultNumberFunctions.java | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java index b4b2d26..15ef42f 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java @@ -57,10 +57,6 @@ public class DefaultNumberFunctions public static final Function ATAN = registerFunc(new Func1("Atan") { @Override protected Value eval1(EvalContext ctx, Value param1) { - Value.Type type = param1.getType(); - if(!type.isNumeric()) { - // FIXME how to handle text/date? - } return BuiltinOperators.toValue(Math.atan(param1.getAsDouble())); } }); @@ -68,10 +64,6 @@ public class DefaultNumberFunctions public static final Function COS = registerFunc(new Func1("Cos") { @Override protected Value eval1(EvalContext ctx, Value param1) { - Value.Type type = param1.getType(); - if(!type.isNumeric()) { - // FIXME how to handle text/date? - } return BuiltinOperators.toValue(Math.cos(param1.getAsDouble())); } }); @@ -79,10 +71,6 @@ public class DefaultNumberFunctions public static final Function EXP = registerFunc(new Func1("Exp") { @Override protected Value eval1(EvalContext ctx, Value param1) { - Value.Type type = param1.getType(); - if(!type.isNumeric()) { - // FIXME how to handle text/date? - } return BuiltinOperators.toValue(Math.exp(param1.getAsDouble())); } }); @@ -90,11 +78,7 @@ public class DefaultNumberFunctions public static final Function FIX = registerFunc(new Func1NullIsNull("Fix") { @Override protected Value eval1(EvalContext ctx, Value param1) { - Value.Type type = param1.getType(); - if(!type.isNumeric()) { - // FIXME how to handle text/date? - } - if(type.isIntegral()) { + if(param1.getType().isIntegral()) { return param1; } return BuiltinOperators.toValue(param1.getAsDouble().longValue()); @@ -104,17 +88,20 @@ public class DefaultNumberFunctions public static final Function INT = registerFunc(new Func1NullIsNull("Int") { @Override protected Value eval1(EvalContext ctx, Value param1) { - Value.Type type = param1.getType(); - if(!type.isNumeric()) { - // FIXME how to handle text/date? - } - if(type.isIntegral()) { + if(param1.getType().isIntegral()) { return param1; } return BuiltinOperators.toValue((long)Math.floor(param1.getAsDouble())); } }); + public static final Function LOG = registerFunc(new Func1("Log") { + @Override + protected Value eval1(EvalContext ctx, Value param1) { + return BuiltinOperators.toValue(Math.log(param1.getAsDouble())); + } + }); + public static final Function RND = registerFunc(new FuncVar("Rnd", 0, 1) { @Override public boolean isPure() { @@ -171,6 +158,20 @@ public class DefaultNumberFunctions } }); + public static final Function SIN = registerFunc(new Func1("Sin") { + @Override + protected Value eval1(EvalContext ctx, Value param1) { + return BuiltinOperators.toValue(Math.sin(param1.getAsDouble())); + } + }); + + public static final Function TAN = registerFunc(new Func1("Tan") { + @Override + protected Value eval1(EvalContext ctx, Value param1) { + return BuiltinOperators.toValue(Math.tan(param1.getAsDouble())); + } + }); + // public static final Function Val = registerFunc(new Func1("Val") { // @Override // protected Value eval1(EvalContext ctx, Value param1) { -- cgit v1.2.3