| java.lang.Object org.geotools.resources.XMath
XMath | final public class XMath (Code) | | Simple mathematical functions. Some of these functions will be removed if JavaSoft provide a
standard implementation or fix some issues in Bug Parade:
since: 2.0 version: $Id: XMath.java 26695 2007-08-23 18:58:56Z desruisseaux $ author: Martin Desruisseaux |
Field Summary | |
final public static double | LN10 Natural logarithm of 10. |
Method Summary | |
public static double | cbrt(double x) Combute the cubic root of the specified value. | public static int | countFractionDigits(double value) Count the fraction digits in the string representation of
the specified value. | public static double | fixRoundingError(double value, int n) Try to remove at least
n fraction digits in the string representation of
the specified value. | public static int | getBitCount(Class type) Returns the number of bits used by number of the specified type.
Parameters: type - The type (may be null ). | public static double | hypot(double x, double y) Compute the hypotenuse (sqrt(x²+y²) ). | public static boolean | isInteger(Class type) Returns
true if the specified
type is one of integer types.
Integer types includes
Long ,
Integer ,
Short and
Byte .
Parameters: type - The type to test (may be null ). | public static boolean | isReal(Class type) Returns
true if the specified
type is one of real
number types. | public static double | log10(double x) Compute the logarithm in base 10. | public static float | next(float f) Finds the least float greater than f. | public static double | next(double f) Finds the least double greater than f. | public static double | pow10(double x) Compute 10 power x. | public static strictfp double | pow10(int x) Compute x to the power of 10. | public static float | previous(float f) Finds the greatest float less than f. | public static double | previous(double f) Finds the greatest double less than f. | public static Class | primitiveToWrapper(Class type) Change a primitive class to its wrapper (e.g. | public static double | rool(Class type, double value, int amount) Returns the next or previous representable number. | public 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. | public static int | sgn(double x) Returns the sign of x. | public static int | sgn(float x) Returns the sign of x. | public static int | sgn(long x) Returns the sign of x. | public static int | sgn(int x) Returns the sign of x. | public static short | sgn(short x) Returns the sign of x. | public static byte | sgn(byte x) Returns the sign of x. | public static float | toNaN(int index) Returns a
Float.NaN NaN number for the specified index. | public static Object | valueOf(Class type, String value) Converts the specified string into a value object. |
LN10 | final public static double LN10(Code) | | Natural logarithm of 10.
Approximately equal to 2.302585.
|
cbrt | public static double cbrt(double x)(Code) | | Combute the cubic root of the specified value. This is method will be removed if
RFE
4633024 is implemented.
|
countFractionDigits | public static int countFractionDigits(double value)(Code) | | Count the fraction digits in the string representation of
the specified value. This method is equivalent to a call to
(value)
and counting the number of digits after the decimal separator.
|
fixRoundingError | public static double fixRoundingError(double value, int n)(Code) | | Try to remove at least
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 .
Parameters: value - The value to fix. Parameters: n - The minimum amount of fraction digits. The fixed value, or the unchanged value if there is no small changethat remove at least n fraction digits. |
getBitCount | public static int getBitCount(Class type)(Code) | | Returns the number of bits used by number of the specified type.
Parameters: type - The type (may be null ). The number of bits, or 0 if unknow. |
hypot | public static double hypot(double x, double y)(Code) | | Compute the hypotenuse (sqrt(x²+y²) ).
|
isInteger | public static boolean isInteger(Class type)(Code) | | Returns
true if the specified
type is one of integer types.
Integer types includes
Long ,
Integer ,
Short and
Byte .
Parameters: type - The type to test (may be null ). true if type is the class Long, Integer,Short or Byte. |
isReal | public static boolean isReal(Class type)(Code) | | Returns
true if the specified
type is one of real
number types. Real number types includes
Float and
Double .
Parameters: type - The type to test (may be null ). true if type is the class Float or Double. |
log10 | public static double log10(double x)(Code) | | Compute the logarithm in base 10. See
http://developer.java.sun.com/developer/bugParade/bugs/4074599.html.
|
next | public static float next(float f)(Code) | | Finds the least float greater than f.
If
NaN , returns same value.
|
pow10 | public static double pow10(double x)(Code) | | Compute 10 power x.
|
pow10 | public static strictfp double pow10(int x)(Code) | | Compute x to the power of 10. This computation is very fast
for small power of 10 but has some rounding error issues (see
http://developer.java.sun.com/developer/bugParade/bugs/4358794.html).
|
previous | public static float previous(float f)(Code) | | Finds the greatest float less than f.
If
NaN , returns same value.
|
primitiveToWrapper | public static Class primitiveToWrapper(Class type)(Code) | | Change a primitive class to its wrapper (e.g.
double to
Double ).
If the specified class is not a primitive type, then it is returned unchanged.
Parameters: type - The primitive type (may be null ). The type as a wrapper. |
rool | public static double rool(Class type, double value, int amount) throws IllegalArgumentException(Code) | | Returns the next or previous representable number. If
amount is equals to
0 , then this method returns the
value unchanged. Otherwise,
The operation performed depends on the specified
type :
Parameters: type - The type. Should be the class of Double, Float,Long, Integer, Short or Byte. Parameters: value - The number to rool. Parameters: amount - -1 to return the previous representable number,+1 to return the next representable number, or0 to return the number with no change. One of previous or next representable number as a double . throws: IllegalArgumentException - if type is not one of supported types. |
round | public static double round(double value, int flu)(Code) | | 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. This
method can be used for hiding floating point error likes 2.9999999996.
Parameters: value - The value to round. Parameters: flu - The amount of floating point units. The rounded value, of value if it was not close enough to an integer. |
sgn | public static int sgn(double x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null or
NaN and
+1 if x is positive.
|
sgn | public static int sgn(float x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null or
NaN and
+1 if x is positive.
|
sgn | public static int sgn(long x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null and
+1 if x is positive.
|
sgn | public static int sgn(int x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null and
+1 if x is positive.
|
sgn | public static short sgn(short x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null and
+1 if x is positive.
|
sgn | public static byte sgn(byte x)(Code) | | Returns the sign of x. This method returns
-1 if x is negative,
0 if x is null and
+1 if x is positive.
|
toNaN | public static float toNaN(int index) throws IndexOutOfBoundsException(Code) | | Returns a
Float.NaN NaN number for the specified index. Valid NaN numbers have
bit fields ranging from
0x7f800001 through
0x7fffffff or
0xff800001 through
0xffffffff . The standard
Float.NaN has bit fields
0x7fc00000 .
Parameters: index - The index, from -2097152 to 2097151 inclusive. One of the legal Float.NaN NaN values as a float. throws: IndexOutOfBoundsException - if the specified index is out of bounds. |
|
|