Package ucar.nc2.ogc.erddap.util
Class ErddapMath2
- java.lang.Object
-
- ucar.nc2.ogc.erddap.util.ErddapMath2
-
public class ErddapMath2 extends Object
The Math2 class has several static Math-related methods.- These are low level routines used by most other CoHort classes.
- Many provide additional protection from run-time errors.
-
-
Field Summary
Fields Modifier and Type Field Description static String
memoryArraySize
static String
memoryTooMuchData
These are *not* final so EDStatic can replace them with translated Strings.
-
Constructor Summary
Constructors Constructor Description ErddapMath2()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
ensureArraySizeOkay(long tSize, String attributeTo)
Even if JavaBits is 64, the limit on an array size is Integer.MAX_VALUE.static boolean
isFinite(double d)
Checks if the value is not NaN or +-Infinite.static int
roundToInt(double d)
Safely rounds a double to an int.
-
-
-
Method Detail
-
isFinite
public static boolean isFinite(double d)
Checks if the value is not NaN or +-Infinite. This works for floats.- Parameters:
d
- any double value or float value- Returns:
- true if d is is not NaN or +/-infinity.
-
ensureArraySizeOkay
public static void ensureArraySizeOkay(long tSize, String attributeTo)
Even if JavaBits is 64, the limit on an array size is Integer.MAX_VALUE.This is almost identical to EDStatic.ensureArraySizeOkay, but lacks tallying.
- Parameters:
tSize
-attributeTo
- for a WARNING or ERROR message, this is the string to which this not-enough-memory issue should be attributed.
-
roundToInt
public static int roundToInt(double d)
Safely rounds a double to an int. (Math.round but rounds to a long and not safely.)- Parameters:
d
- any double- Returns:
- Integer.MAX_VALUE if d is too small, too big, or NaN; otherwise d, rounded to the nearest int. Undesirable: d.5 rounds up for positive numbers, down for negative.
-
-