Package com.nomagic.reportwizard.tools
Class MathTool
java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.Tool
com.nomagic.reportwizard.tools.MathTool
- All Implemented Interfaces:
ITool,IVariable,Serializable,Cloneable
Provide basic numeric operations for report.
- Since:
- Jun 6, 2008
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.nomagic.magicreport.engine.ITool
ITool.HTMLString, ITool.RetainedString, ITool.Void -
Field Summary
Fields inherited from class com.nomagic.magicreport.engine.Tool
context, properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleabs(double a) Returns the absolute value of andoublevalue.static intabs(int a) Returns the absolute value of anintvalue.static doubleceil(double a) Returns the smallest (closest to negative infinity)doublevalue that is greater than or equal to the argument and is equal to a mathematical integer.static doublefloor(double a) Returns the largest (closest to positive infinity)doublevalue that is less than or equal to the argument and is equal to a mathematical integer.static doublemax(double a, double b) Returns the greater of twodoublevalues.static intmax(int a, int b) Returns the greater of twointvalues.static doublemin(double a, double b) Returns the smaller of twodoublevalues.static intmin(int a, int b) Returns the smaller of twointvalues.static longround(double a) Returns the closestlongto the argument.Methods inherited from class com.nomagic.magicreport.engine.Tool
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setPropertiesMethods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
Constructor Details
-
MathTool
public MathTool()
-
-
Method Details
-
abs
public static int abs(int a) Returns the absolute value of anintvalue. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.- Parameters:
a- the argument whose absolute value is to be determined- Returns:
- the absolute value of the argument.
-
abs
public static double abs(double a) Returns the absolute value of andoublevalue. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.- Parameters:
a- the argument whose absolute value is to be determined- Returns:
- the absolute value of the argument.
-
ceil
public static double ceil(double a) Returns the smallest (closest to negative infinity)doublevalue that is greater than or equal to the argument and is equal to a mathematical integer. Special cases:- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
- If the argument value is less than zero but greater than -1.0, then the result is negative zero.
- Parameters:
a- a value.- Returns:
- the smallest (closest to negative infinity) floating-point value that is greater than or equal to the argument and is equal to a mathematical integer.
-
floor
public static double floor(double a) Returns the largest (closest to positive infinity)doublevalue that is less than or equal to the argument and is equal to a mathematical integer. Special cases:- If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
- Parameters:
a- a value.- Returns:
- the largest (closest to positive infinity) floating-point value that less than or equal to the argument and is equal to a mathematical integer.
-
max
public static int max(int a, int b) Returns the greater of twointvalues. If the arguments have the same value, the result is that same value.- Parameters:
a- an argument.b- another argument.- Returns:
- the larger of
aandb.
-
max
public static double max(double a, double b) Returns the greater of twodoublevalues. If the arguments have the same value, the result is that same value.- Parameters:
a- an argument.b- another argument.- Returns:
- the larger of
aandb.
-
min
public static int min(int a, int b) Returns the smaller of twointvalues. If the arguments have the same value, the result is that same value.- Parameters:
a- an argument.b- another argument.- Returns:
- the smaller of
aandb.
-
min
public static double min(double a, double b) Returns the smaller of twodoublevalues. If the arguments have the same value, the result is that same value.- Parameters:
a- an argument.b- another argument.- Returns:
- the smaller of
aandb.
-
round
public static long round(double a) Returns the closestlongto the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to typelong.- Parameters:
a- a floating-point value to be rounded to along.- Returns:
- the value of the argument rounded to the nearest
longvalue.
-