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

com.graphbuilder.math.func.RoundFunction Maven / Gradle / Ivy

Go to download

Implementation of various mathematical curves that define themselves over a set of control points. The API is written in Java. The curves supported are: Bezier, B-Spline, Cardinal Spline, Catmull-Rom Spline, Lagrange, Natural Cubic Spline, and NURBS.

There is a newer version: 1.08
Show newest version
package com.graphbuilder.math.func;

/**
The round function.

@see java.lang.Math#round(double)
*/
public class RoundFunction implements Function {

	public RoundFunction() {}

	/**
	Returns the value at d[0] rounded to the nearest integer value.
	If the value exceeds the capabilities of long precision then
	the value itself is returned.
	*/
	public double of(double[] d, int numParam) {
		if (d[0] >= Long.MAX_VALUE || d[0] <= Long.MIN_VALUE)
			return d[0];

		return Math.round(d[0]);
	}

	/**
	Returns true only for 1 parameter, false otherwise.
	*/
	public boolean acceptNumParam(int numParam) {
		return numParam == 1;
	}

	public String toString() {
		return "round(x)";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy