diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2017-09-20 05:04:31 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2017-09-20 05:04:31 +0000 |
commit | e30e81c0994f31701be56d124ab3cef150e51129 (patch) | |
tree | 3624749d05afbcfa7bf8baeee6cf5dbdc04538da | |
parent | 1f7373e77b7e6487bb480508e32aef31e26e6ec2 (diff) | |
download | jackcess-e30e81c0994f31701be56d124ab3cef150e51129.tar.gz jackcess-e30e81c0994f31701be56d124ab3cef150e51129.zip |
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
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/expr/DefaultNumberFunctions.java | 45 |
1 files 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) { |