Package mgui.numbers
Class NumberFunctions
java.lang.Object
mgui.numbers.NumberFunctions
public class NumberFunctions
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description NumberFunctions() -
Method Summary
Modifier and Type Method Description static intceilToOdd(double d)static intcompare(double d1, double d2, double precision)Compares two numbers within a given precision (number of zeros).static java.text.DecimalFormatgetDecimalFormat(int decimal_places)static java.text.DecimalFormatgetDecimalFormat(int decimal_places, boolean dividers)static MguiDoublegetDifference(MguiNumber n1, MguiNumber n2)static MguiNumbergetInstance(java.lang.Class<?> clazz, double value)Returns an instance of an MguiNumber of the specified class and value.static MguiNumbergetInstance(java.lang.String type, double value)Returns an instance of an MguiNumber of the specified type and valuestatic MguiNumbergetInstance(DataType type, double value)Returns an instance of an MguiNumber of the specified type and valuestatic intgetMultiple(double d1, double d2)static doublegetNextSquare(double n)Returns the next highest square numberstatic java.lang.StringgetPoint2fStr(org.jogamp.vecmath.Point2f p, java.lang.String pattern)static java.lang.StringgetPoint3dStr(org.jogamp.vecmath.Point3d p, java.lang.String pattern)static MguiDoublegetProduct(MguiNumber n1, MguiNumber n2)static MguiDoublegetQuotient(MguiNumber n1, MguiNumber n2)static java.lang.StringgetReasonableFormat(double d)static java.lang.StringgetReasonableString(double d)static doublegetSum(double[] n)static MguiDoublegetSum(MguiNumber n1, MguiNumber n2)static doublegetValueForObject(java.lang.Object obj)Determines the numeric value ofobjand returns it as adouble.static booleanisEven(double value)static booleanisNumeric(java.lang.Object obj)Determines whetherobjis numeric; i.e., an instance ofMguiNumber(except arBoolean), or a Java primitive wrapper (one ofInteger,Short,Float, orDouble).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
NumberFunctions
public NumberFunctions()
-
-
Method Details
-
compare
public static int compare(double d1, double d2, double precision)Compares two numbers within a given precision (number of zeros). Returns -1 if d1 < d2, +1 if d1 > d2, zero otherwise.- Parameters:
d1-d2-precision-- Returns:
-
getMultiple
public static int getMultiple(double d1, double d2) -
ceilToOdd
public static int ceilToOdd(double d) -
getInstance
Returns an instance of an MguiNumber of the specified type and value- Parameters:
type-value-- Returns:
-
getInstance
Returns an instance of an MguiNumber of the specified class and value. Returnsnullif instantiation failed.- Parameters:
type-value-- Returns:
-
getInstance
Returns an instance of an MguiNumber of the specified type and value- Parameters:
type- : Name of MguiNumber subclassvalue-- Returns:
-
getDecimalFormat
public static java.text.DecimalFormat getDecimalFormat(int decimal_places) -
getDecimalFormat
public static java.text.DecimalFormat getDecimalFormat(int decimal_places, boolean dividers) -
getPoint2fStr
public static java.lang.String getPoint2fStr(org.jogamp.vecmath.Point2f p, java.lang.String pattern) -
isEven
public static boolean isEven(double value) -
getPoint3dStr
public static java.lang.String getPoint3dStr(org.jogamp.vecmath.Point3d p, java.lang.String pattern) -
getDifference
-
getProduct
-
getQuotient
-
getSum
-
getNextSquare
public static double getNextSquare(double n)Returns the next highest square number -
getSum
public static double getSum(double[] n) -
getReasonableString
public static java.lang.String getReasonableString(double d) -
getReasonableFormat
public static java.lang.String getReasonableFormat(double d) -
getValueForObject
public static double getValueForObject(java.lang.Object obj)Determines the numeric value ofobjand returns it as adouble.objmust be an instance ofarNumber, or a Java primitive wrapper (one ofInteger,Short,Float, orDouble).If
objdoes not satisfy these criteria,Double.NaNis returned.- Parameters:
obj-- Returns:
-
isNumeric
public static boolean isNumeric(java.lang.Object obj)Determines whetherobjis numeric; i.e., an instance ofMguiNumber(except arBoolean), or a Java primitive wrapper (one ofInteger,Short,Float, orDouble).- Parameters:
obj-- Returns:
trueif numeric,falseotherwise.
-