svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / numeric / CeilFunction.java @ 44009
History | View | Annotate | Download (1.41 KB)
1 |
package org.gvsig.expressionevaluator.impl.function.numeric; |
---|---|
2 |
|
3 |
import org.apache.commons.lang3.Range; |
4 |
import org.gvsig.expressionevaluator.Interpreter; |
5 |
import org.gvsig.expressionevaluator.spi.AbstractFunction; |
6 |
|
7 |
public class CeilFunction extends AbstractFunction { |
8 |
|
9 |
public CeilFunction() {
|
10 |
super("Numeric", "CEIL", Range.is(1), |
11 |
"Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. Special cases:\n" +
|
12 |
"- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.\n" +
|
13 |
"- If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.\n" +
|
14 |
"- If the argument value is less than zero but greater than -1.0, then the result is negative zero.\n" +
|
15 |
"Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).",
|
16 |
"CEIL({{a}})",
|
17 |
new String[]{ |
18 |
"a - a value."
|
19 |
}, |
20 |
"Double",
|
21 |
true
|
22 |
); |
23 |
this.addAlias("CEILING"); |
24 |
} |
25 |
|
26 |
@Override
|
27 |
public boolean allowConstantFolding() { |
28 |
return true; |
29 |
} |
30 |
|
31 |
@Override
|
32 |
public Object call(Interpreter interpreter, Object[] args) { |
33 |
double r = Math.ceil(getDouble(args, 0)); |
34 |
return r;
|
35 |
} |
36 |
|
37 |
|
38 |
} |