All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jason.functions.floor Maven / Gradle / Ivy

Go to download

Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent-oriented logic programming language.

The newest version!
package jason.functions;

import jason.JasonException;
import jason.asSemantics.DefaultArithFunction;
import jason.asSemantics.TransitionSystem;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.Term;

/**
  

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

Examples:

  • math.floor(3.1): returns 3.
  • math.floor(3.9): returns 3.
@author Jomi @see jason.functions.Random @see jason.functions.ceil */ public class floor extends DefaultArithFunction { public String getName() { return "math.floor"; } @Override public double evaluate(TransitionSystem ts, Term[] args) throws Exception { if (args[0].isNumeric()) { double n = ((NumberTerm)args[0]).solve(); return Math.floor(n); } else { throw new JasonException("The argument '"+args[0]+"' is not numeric!"); } } @Override public boolean checkArity(int a) { return a == 1; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy