Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jason.functions;
 

Function: math.ceil(N): encapsulates java Math.ceil(N), returns the smallest double value that is not less than the argument and is equal to a mathematical integer.

Examples:

  • math.ceil(3.1): returns 4.
  • math.ceil(3.9): returns 4.

Author(s):
Jomi
See also:
floor
Random
public class ceil extends DefaultArithFunction  {
    public String getName() {
        return "math.ceil";
    }
    
    @Override
    public double evaluate(TransitionSystem tsTerm[] argsthrows Exception {
        if (args[0].isNumeric()) {
            double n = ((NumberTerm)args[0]).solve();
            return Math.ceil(n);
        } else {
            throw new JasonException("The argument '"+args[0]+"' is not numeric!");
        }
    }
    @Override
    public boolean checkArity(int a) {
        return a == 1;
    }
    
New to GrepCode? Check out our FAQ X