|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.resources.XMath
Simple mathematical functions. Some of these functions will
be removed if JavaSoft provide a standard implementation
or fix some issues in Bug Parade:
Field Summary | |
static double |
LN10
Natural logarithm of 10. |
Method Summary | |
static double |
cbrt(double x)
Combute the cubic root of the specified value. |
static int |
countFractionDigits(double value)
Count the fraction digits in the string representation of the specified value. |
static double |
fixRoundingError(double value,
int n)
Try to remove at least n fraction digits in the string representation of
the specified value. |
static int |
getBitCount(java.lang.Class type)
Returns the number of bits used by number of the specified type. |
static double |
hypot(double x,
double y)
Compute the hypotenuse ( sqrt(x�+y�) ). |
static boolean |
isInteger(java.lang.Class type)
Returns true if the specified type is one of integer types.
|
static boolean |
isReal(java.lang.Class type)
Returns true if the specified type is one of real
number types. |
static double |
log10(double x)
Compute the logarithm in base 10. |
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 |
pow10(double x)
Compute 10 power x. |
static double |
pow10(int x)
Compute x to the power of 10. |
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 java.lang.Class |
primitiveToWrapper(java.lang.Class type)
Change a primitive class to its wrapper (e.g. |
static double |
rool(java.lang.Class type,
double value,
int amount)
Returns the next or previous representable number. |
static double |
round(double value,
int flu)
Round the specified value, providing that the difference between the original value and the rounded value is not greater than the specified amount of floating point units. |
static byte |
sgn(byte x)
Returns the sign of x. |
static int |
sgn(double x)
Returns the sign of x. |
static int |
sgn(float x)
Returns the sign of x. |
static int |
sgn(int x)
Returns the sign of x. |
static int |
sgn(long x)
Returns the sign of x. |
static short |
sgn(short x)
Returns the sign of x. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final double LN10
Method Detail |
public static double cbrt(double x)
public static double hypot(double x, double y)
sqrt(x�+y�)
).
public static double log10(double x)
public static double pow10(double x)
public static double pow10(int x)
public static int sgn(double x)
NaN
and
+1 if x is positive.
public static int sgn(float x)
NaN
and
+1 if x is positive.
public static int sgn(long x)
public static int sgn(int x)
public static short sgn(short x)
public static byte sgn(byte x)
public static double round(double value, int flu)
value
- The value to round.flu
- The amount of floating point units.
value
if it was not close enough to an integer.public static double fixRoundingError(double value, int n)
n
fraction digits in the string representation of
the specified value. This method try small changes to value
, by adding or
substracting a maximum of 4 ulps. If there is no small change that remove at least
n
fraction digits, then the value is returned unchanged. This method is
used for hiding rounding errors, like in conversions from radians to degrees.
Example: XMath.fixRoundingError(-61.500000000000014, 12)
returns
-61.5
.
value
- The value to fix.
value
if there is no small change
that remove at least n
fraction digits.public static int countFractionDigits(double value)
Double#toString(value)
and counting the number of digits after the decimal separator.
public static float next(float f)
NaN
, returns same value.
public static float previous(float f)
NaN
, returns same value.
public static double next(double f)
NaN
, returns same value.
ChoiceFormat.nextDouble(double)
public static double previous(double f)
NaN
, returns same value.
ChoiceFormat.previousDouble(double)
public static double rool(java.lang.Class type, double value, int amount) throws java.lang.IllegalArgumentException
amount
is equals to
0
, then this method returns the value
unchanged. Otherwise,
The operation performed depends on the specified type
:
If the type
is Double
, then this method is
equivalent to invoking previous(double)
if amount
is equals to
-1
, or invoking next(double)
if amount
is equals to
+1
. If amount
is smaller than -1
or greater
than +1
, then this method invokes previous(double)
or
next(double)
in a loop for abs(amount)
times.
If the type
is Float
, then this method is
equivalent to invoking previous(float)
if amount
is equals to
-1
, or invoking next(float)
if amount
is equals to
+1
. If amount
is smaller than -1
or greater
than +1
, then this method invokes previous(float)
or
next(float)
in a loop for abs(amount)
times.
If the type
is an integer, then invoking
this method is equivalent to computing value + amount
.
type
- The type. Should be the class of Double
, Float
,
Long
, Integer
, Short
or Byte
.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.
double
.
java.lang.IllegalArgumentException
- if type
is not one of supported types.public static boolean isReal(java.lang.Class type)
true
if the specified type
is one of real
number types. Real number types includes Float
and Double
.
type
- The type to test (may be null
).
true
if type
is the class Float
or Double
.public static boolean isInteger(java.lang.Class type)
true
if the specified type
is one of integer types.
Integer types includes Long
, Integer
, Short
and Byte
.
type
- The type to test (may be null
).
true
if type
is the class Long
, Integer
,
Short
or Byte
.public static int getBitCount(java.lang.Class type)
type
- The type (may be null
).
public static java.lang.Class primitiveToWrapper(java.lang.Class type)
double
to Double
).
If the specified class is not a primitive type, then it is returned unchanged.
type
- The primitive type (may be null
).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |