Package org.geotools.util
Class XMath
- Object
-
- XMath
-
public final class XMath extends Object
Simple mathematical functions.- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
next(double f)
Finds the least double greater than f.static float
next(float f)
Finds the least float greater than f.static double
previous(double f)
Finds the greatest double less than f.static float
previous(float f)
Finds the greatest float less than f.static double
rool(Class type, double value, int amount)
Returns the next or previous representable number.
-
-
-
Method Detail
-
next
public static float next(float f)
Finds the least float greater than f. IfNaN
, returns same value.
-
previous
public static float previous(float f)
Finds the greatest float less than f. IfNaN
, returns same value.
-
next
public static double next(double f)
Finds the least double greater than f. IfNaN
, returns same value.- See Also:
ChoiceFormat.nextDouble(double)
-
previous
public static double previous(double f)
Finds the greatest double less than f. IfNaN
, returns same value.- See Also:
ChoiceFormat.previousDouble(double)
-
rool
public static double rool(Class type, double value, int amount) throws IllegalArgumentException
Returns the next or previous representable number. Ifamount
is equals to0
, then this method returns thevalue
unchanged. Otherwise, The operation performed depends on the specifiedtype
:-
If the
type
isDouble
, then this method is equivalent to invokingprevious(double)
ifamount
is equals to-1
, or invokingnext(double)
ifamount
is equals to+1
. Ifamount
is smaller than-1
or greater than+1
, then this method invokesprevious(double)
ornext(double)
in a loop forabs(amount)
times. -
If the
type
isFloat
, then this method is equivalent to invokingprevious(float)
ifamount
is equals to-1
, or invokingnext(float)
ifamount
is equals to+1
. Ifamount
is smaller than-1
or greater than+1
, then this method invokesprevious(float)
ornext(float)
in a loop forabs(amount)
times. -
If the
type
is an integer, then invoking this method is equivalent to computingvalue + amount
.
- Parameters:
type
- The type. Should be the class ofDouble
,Float
,Long
,Integer
,Short
orByte
.value
- The number to rool.amount
- -1 to return the previous representable number, +1 to return the next representable number, or 0 to return the number with no change.- Returns:
- One of previous or next representable number as a
double
. - Throws:
IllegalArgumentException
- iftype
is not one of supported types.
-
-
-