Java Code Examples for java.lang.Math#rint()

The following examples show how to use java.lang.Math#rint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Round.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private Object round(Object l, Object r) throws ParseException {
	if (l instanceof Number && r instanceof Number)
	{
		int dp = ((Number)r).intValue();
		double val = ((Number)l).doubleValue();
		double mul = Math.pow(10,dp);
		return new Double(Math.rint(val*mul)/mul);
	}
	throw new ParseException("Invalid parameter type");
}
 
Example 2
Source File: Round.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
public Object round(Object param)
	throws ParseException
{
	if (param instanceof Number)
	{
		return new Double(Math.rint(((Number)param).doubleValue()));
	}

	throw new ParseException("Invalid parameter type");
}
 
Example 3
Source File: SystemFunctions.java    From incubator-retired-mrql with Apache License 2.0 votes vote down vote up
public static MR_double rint ( MR_double x ) { return new MR_double(Math.rint(x.get())); }