j2meClient.J2MEDouble Class Reference

A software implementation of IEEE-754 double precision math which does not rely on the double data type. More...


Public Member Functions

long doubleValue ()
 Returns the double value of this J2MEDouble object.
boolean equals (Object obj)
 Compares this object against the specified object.
int hashCode ()
 Returns a hash code for this J2MEDouble object.
 J2MEDouble (String s)
 Constructs a newly-allocated J2MEDouble object that represents the argument.
 J2MEDouble (long d)
 Constructs a newly-allocated J2MEDouble object that represents the argument.
String toString ()
 Returns a String object representing this J2MEDouble's value.

Static Public Member Functions

static long abs (long d)
 Mimics Math.abs(double).
static long acos (long d)
 Mimics Math.acos(double).
static long acosh (long d)
 Returns the arc hyperbolic cosine of an angle.
static long add (long d1, long d2)
 Returns the sum of the two double arguments according to section 15.18.2 of the JLS.
static final long asin (long d)
 Mimics Math.asin(double).
static long asinh (long d)
 Returns the arc hyperbolic sine of an angle.
static long atan (long d)
 Mimics Math.atan(double).
static long atanh (long d)
 Returns the arc hyperbolic tangent of an angle.
static byte byteValue (long d)
 Convert the given double to a byte as would happen in a casting operation specified by section 5.1.3 of the JLS.
static long ceil (long d)
 Mimcs Math.ceil(double).
static long combinations (long d1, long d2)
 Return the number of ways of obtaining an unordered subset of d2 elements from a set of d1 elements.
static int compare (long d1, long d2)
 Mimics Double.compare(double, double).
static long cos (long d)
 Mimics Math.cos(double).
static long cosh (long d)
 Returns the hyperbolic cosine of an angle.
static long div (long d1, long d2)
 Returns the quotient of the two double arguments according to section 15.17.2 of the JLS.
static boolean eq (long d1, long d2)
 Returns true if the specified numbers are considered equal according to section 15.21.1 of the JLS.
static long exp (long d)
 Mimics Math.exp(double).
static long expm1 (long d)
 Returns Euler's number e raised to the power of a double value, less 1, computed in a way that is accurate even when the value of d is close to zero.
static long factorial (long d)
 Returns the factorial of d.
static long floatToDouble (int f)
 Convert the given float to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.
static int floatValue (long d)
 Convert the given double to a float as would happen in a casting operation specified by section 5.1.3 of the JLS.
static long floor (long d)
 Mimics Math.floor(double).
static long gamma (long d)
 Returns the complete gamma function of d.
static boolean ge (long d1, long d2)
 Returns true if the first argument is considered greater than or equal to the second argument according to section 15.20.1 of the JLS.
static boolean gt (long d1, long d2)
 Returns true if the first argument is considered greater than the second argument according to section 15.20.1 of the JLS.
static long IEEEremainder (long d1, long d2)
 Mimics Math.IEEEremainder(double, double).
static long intToDouble (int x)
 Convert the given int to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.
static int intValue (long d)
 Convert the given double to an int as would happen in a casting operation specified by section 5.1.3 of the JLS.
static boolean isInfinite (long d)
 Mimics Double.isInfinite(double).
static boolean isNaN (long d)
 Mimics Double.isNaN(double).
static boolean isZero (long d)
 Returns true if the specified number has zero magnitude, false otherwise.
static boolean le (long d1, long d2)
 Returns true if the first argument is considered less than or equal to the second argument according to section 15.20.1 of the JLS.
static long lgamma (long d)
 Returns the natural logarithm of the absolute value of the gamma function of d.
static long log (long d)
 Mimics Math.log(double).
static long log (long d, long base)
 Returns the logarithm of a double value using a specified base.
static long log10 (long d)
 Returns the base 10 logarithm of a double value.
static long log1p (long d)
 Returns the natural logarithm of 1 + d, computed in a way that is accurate even when the value of d is close to zero.
static long longToDouble (long x)
 Convert the given long to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.
static long longValue (long d)
 Convert the given double to a long as would happen in a casting operation specified by section 5.1.3 of the JLS.
static boolean lt (long d1, long d2)
 Returns true if the first argument is considered less than the second argument according to section 15.20.1 of the JLS.
static long max (long d1, long d2)
 Mimics Math.max(double, double).
static long min (long d1, long d2)
 Mimics Math.min(double, double).
static long mod (long d1, long d2)
 Returns the remainder of the two double arguments according to section 15.17.3 of the JLS.
static long mul (long d1, long d2)
 Returns the product of the two double arguments according to section 15.17.1 of the JLS.
static boolean ne (long d1, long d2)
 Returns true if the specified numbers are considered unequal according to section 15.21.1 of the JLS.
static long negate (long d)
 Returns the negation of a double value.
static long parseDouble (String s)
 Mimics Double.parseDouble(String).
static long percentChange (long d1, long d2)
 Returns the difference of d2 and d1, expressed as a percentage of d1.
static long percentTotal (long d1, long d2)
 Returns d2 expressed as a percentage of d1.
static long permutations (long d1, long d2)
 Return the number of ways of obtaining an ordered subset of d2 elements from a set of d1 elements.
static long pow (long d1, long d2)
 Mimics Math.pow(double, double).
static long random ()
 Mimics Math.random().
static long rint (long d)
 Mimics Math.rint(double).
static long round (long d)
 Mimcs Math.round(double).
static long scalbn (long d, int n)
 Returns the value of the first argument, multiplied by 2 raised to the power of the second argument.
static short shortValue (long d)
 Convert the given double to a short as would happen in a casting operation specified by section 5.1.3 of the JLS.
static long sin (long d)
 Mimics Math.sin(double).
static long sinh (long d)
 Returns the hyperbolic sine of an angle.
static long sqrt (long d)
 Mimics Math.sqrt(double).
static long sub (long d1, long d2)
 Returns the difference of the two double arguments according to section 15.18.2 of the JLS.
static long tan (long d)
 Mimics Math.tan(double).
static long tanh (long d)
 Returns the hyperbolic tangent of an angle.
static long toDegrees (long angrad)
 Mimics Math.toDegrees(double).
static long toRadians (long angdeg)
 Mimics Math.toRadians(double).
static String toString (long d, int maxStringLength)
 Returns a string representation of the double argument, rounded so that the returned String is no longer than maxStringLength characters (or 9 characters, if maxStringLength is less than 9).
static String toString (long d)
 Mimics Double.toString(double).
static long truncate (long d)
 Returns the double of greatest magnitude (furthest from zero) that is equal to a mathematical integer and which has a mignitude not greater than the argument's magnitude.

Static Public Attributes

static final long E = 0x4005bf0a8b145769L
 A constant holding the same value as Math.E.
static final long EIGHT = 0x4020000000000000L
 A constant holding the value of 8.0d.
static final long FIVE = 0x4014000000000000L
 A constant holding the value of 5.0d.
static final long FOUR = 0x4010000000000000L
 A constant holding the value of 4.0d.
static final long LN2 = 0x3fe62e42fefa39efL
 A constant holding the natural logarithm of 2.
static final long MAX_VALUE = 0x7fefffffffffffffL
 A constant holding the same value as Double.MAX_VALUE.
static final long MIN_VALUE = 0x0000000000000001L
 A constant holding the same value as Double.MIN_VALUE.
static final long NaN = 0x7ff8000000000000L
 A constant holding the same value as Double.NaN.
static final long NEGATIVE_INFINITY = 0xfff0000000000000L
 A constant holding the same value as Double.NEGATIVE_INFINITY.
static final long NEGATIVE_ONE = 0xbff0000000000000L
 A constant holding the value of -1.0d.
static final long NEGATIVE_ZERO = 0x8000000000000000L
 A constant holding the value of -0.0d.
static final long ONE = 0x3ff0000000000000L
 A constant holding the value of 1.0d.
static final long ONE_EIGHTH = 0x3fc0000000000000L
 A constant holding the value of 0.125d.
static final long ONE_FOURTH = 0x3fd0000000000000L
 A constant holding the value of 0.25d.
static final long ONE_HALF = 0x3fe0000000000000L
 A constant holding the value of 0.5d.
static final long ONE_HUNDRED = 0x4059000000000000L
 A constant holding the value of 100.0d.
static final long ONE_THIRD = 0x3fd5555555555555L
 A constant holding the value of (1.0d / 3.0d).
static final long PI = 0x400921fb54442d18L
 A constant holding the same value as Math.PI.
static final long POSITIVE_INFINITY = 0x7ff0000000000000L
 A constant holding the same value as Double.POSITIVE_INFINITY.
static final long SIX = 0x4018000000000000L
 A constant holding the value of 6.0d.
static final long TEN = 0x4024000000000000L
 A constant holding the value of 10.0d.
static final long THREE = 0x4008000000000000L
 A constant holding the value of 3.0d.
static final long THREE_HALVES = 0x3ff8000000000000L
 A constant holding the value of 1.5d.
static final long TWO = 0x4000000000000000L
 A constant holding the value of 2.0d.
static final long ZERO = 0x0000000000000000L
 A constant holding the value of 0.0d.

Detailed Description

A software implementation of IEEE-754 double precision math which does not rely on the double data type.

This class overloads the long data type by storing double data in it.

See also:
Double

Math

J2MEFloat

Version:
Revision
1.5

Constructor & Destructor Documentation

j2meClient.J2MEDouble.J2MEDouble ( long  d  ) 

Constructs a newly-allocated J2MEDouble object that represents the argument.

Parameters:
d the double value to be represented by the J2MEDouble.

j2meClient.J2MEDouble.J2MEDouble ( String  s  ) 

Constructs a newly-allocated J2MEDouble object that represents the argument.

Parameters:
s a String to be converted to a J2MEDouble.
Exceptions:
NumberFormatException if the String does not contain a parsable number.
See also:
parseDouble(String)


Member Function Documentation

static long j2meClient.J2MEDouble.acosh ( long  d  )  [static]

Returns the arc hyperbolic cosine of an angle.

Parameters:
d the value whose arc hyperbolic cosine is to be returned.
Returns:
the arc hyperbolic cosine of the argument.

static long j2meClient.J2MEDouble.add ( long  d1,
long  d2 
) [static]

Returns the sum of the two double arguments according to section 15.18.2 of the JLS.

This method takes the place of the + operator.

Parameters:
d1 the first double value to be summed.
d2 the second double value to be summed.
Returns:
the sum of the two arguments

static long j2meClient.J2MEDouble.asinh ( long  d  )  [static]

Returns the arc hyperbolic sine of an angle.

Parameters:
d the value whose arc hyperbolic sine is to be returned.
Returns:
the arc hyperbolic sine of the argument.

static long j2meClient.J2MEDouble.atanh ( long  d  )  [static]

Returns the arc hyperbolic tangent of an angle.

Parameters:
d the value whose arc hyperbolic tangent is to be returned.
Returns:
the arc hyperbolic tangent of the argument.

static byte j2meClient.J2MEDouble.byteValue ( long  d  )  [static]

Convert the given double to a byte as would happen in a casting operation specified by section 5.1.3 of the JLS.

This is a narrowing primitive conversion which may result in a loss of magnitude and/or precision.

Note that this is a non-intuitive conversion. If the argument is outside of the range of the byte type, the result is basically meaningless.

Parameters:
d the double to be converted
Returns:
the byte representation of the argument

static long j2meClient.J2MEDouble.combinations ( long  d1,
long  d2 
) [static]

Return the number of ways of obtaining an unordered subset of d2 elements from a set of d1 elements.

Also known as the binomial coefficient. If d1 and d2 are not mathematical integers greater than or equal to zero, or if d1 is less than d2, the return value is NaN.

Parameters:
d1 a double value
d2 a double value
Returns:
d1! / (d2! * (d1 - d2)!)
See also:
factorial(long)

permutations(long, long)

static int j2meClient.J2MEDouble.compare ( long  d1,
long  d2 
) [static]

Mimics Double.compare(double, double).

Note that when using this method (as well as Double.compare), the following rules apply:

  • NaN is considered to be equal to itself and greater than all other double values (including POSITIVE_INFINITY).
  • 0.0 is considered to be greater than -0.0.

static long j2meClient.J2MEDouble.cosh ( long  d  )  [static]

Returns the hyperbolic cosine of an angle.

Parameters:
d an angle, in radians.
Returns:
the hyperbolic cosine of the argument.

static long j2meClient.J2MEDouble.div ( long  d1,
long  d2 
) [static]

Returns the quotient of the two double arguments according to section 15.17.2 of the JLS.

This method takes the place of the / operator.

Parameters:
d1 the double dividend
d2 the double divisor
Returns:
the quotient of the two arguments

static boolean j2meClient.J2MEDouble.eq ( long  d1,
long  d2 
) [static]

Returns true if the specified numbers are considered equal according to section 15.21.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is false
  • Positive zero and negative zero are considered equal

This method takes the place of the == operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the two values are considered equal; false otherwise.

boolean j2meClient.J2MEDouble.equals ( Object  obj  ) 

Compares this object against the specified object.

Equivalent to ((obj instanceof J2MEDouble) && (compare(((J2MEDouble) obj).doubleValue(), doubleValue()) == 0))

See also:
compare(long, long)

static long j2meClient.J2MEDouble.expm1 ( long  d  )  [static]

Returns Euler's number e raised to the power of a double value, less 1, computed in a way that is accurate even when the value of d is close to zero.

Parameters:
d the exponent to raise e to.
Returns:
the value ed - 1, where e is the base of the natural logarithms.
See also:
exp(long)

log1p(long)

static long j2meClient.J2MEDouble.factorial ( long  d  )  [static]

Returns the factorial of d.

If d is not a mathematical integer greater than or equal to zero, the return value is NaN. Use the gamma function for non-integer values.

This is a naive implentation. TODO: make this better.

Parameters:
d a double value.
Returns:
d!

static long j2meClient.J2MEDouble.floatToDouble ( int  f  )  [static]

Convert the given float to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.

This is a widening primitive conversion which will result in neither a loss of magnitude nor precision.

Parameters:
f the float to be converted
Returns:
the double representation of the argument

static int j2meClient.J2MEDouble.floatValue ( long  d  )  [static]

Convert the given double to a float as would happen in a casting operation specified by section 5.1.3 of the JLS.

This is a narrowing primitive conversion which may result in a loss of magnitude and/or precision.

Parameters:
d the double to be converted
Returns:
the float representation of the argument

static long j2meClient.J2MEDouble.gamma ( long  d  )  [static]

Returns the complete gamma function of d.

Parameters:
d a double value
Returns:
Gamma(d)
See also:
lgamma(long)

static boolean j2meClient.J2MEDouble.ge ( long  d1,
long  d2 
) [static]

Returns true if the first argument is considered greater than or equal to the second argument according to section 15.20.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is false
  • Positive zero and negative zero are considered equal
  • Negative infinity is conisdered less than all other values except NaN
  • Positive infinity is conisdered greater than all other values except NaN

This method takes the place of the >= operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the first value is greater than or equal to the second value; false otherwise.

static boolean j2meClient.J2MEDouble.gt ( long  d1,
long  d2 
) [static]

Returns true if the first argument is considered greater than the second argument according to section 15.20.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is false
  • Positive zero and negative zero are considered equal
  • Negative infinity is conisdered less than all other values except NaN
  • Positive infinity is conisdered greater than all other values except NaN

This method takes the place of the > operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the first value is greater than the second value; false otherwise.

int j2meClient.J2MEDouble.hashCode (  ) 

Returns a hash code for this J2MEDouble object.

Equivalent to (int) (doubleValue() ^ (doubleValue >>> 32))

static long j2meClient.J2MEDouble.intToDouble ( int  x  )  [static]

Convert the given int to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.

This is a widening primitive conversion which will result in neither a loss of magnitude nor precision.

Parameters:
x the int to be converted
Returns:
the double representation of the argument

static int j2meClient.J2MEDouble.intValue ( long  d  )  [static]

Convert the given double to an int as would happen in a casting operation specified by section 5.1.3 of the JLS.

This is a narrowing primitive conversion which may result in a loss of magnitude and/or precision.

Parameters:
d the double to be converted
Returns:
the int representation of the argument

static boolean j2meClient.J2MEDouble.isZero ( long  d  )  [static]

Returns true if the specified number has zero magnitude, false otherwise.

Parameters:
d the double value to be tested.
Returns:
true if the value of the argument is positive zero or negative zero; false otherwise.

static boolean j2meClient.J2MEDouble.le ( long  d1,
long  d2 
) [static]

Returns true if the first argument is considered less than or equal to the second argument according to section 15.20.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is false
  • Positive zero and negative zero are considered equal
  • Negative infinity is conisdered less than all other values except NaN
  • Positive infinity is conisdered greater than all other values except NaN

This method takes the place of the <= operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the first value is less than or equal to the second value; false otherwise.

static long j2meClient.J2MEDouble.lgamma ( long  d  )  [static]

Returns the natural logarithm of the absolute value of the gamma function of d.

Parameters:
d a double value
Returns:
Log(|Gamma(d)|)
See also:
gamma(long)

static long j2meClient.J2MEDouble.log ( long  d,
long  base 
) [static]

Returns the logarithm of a double value using a specified base.

For most arguments, the return value is computed as: log(d) / log(base). If base is E or 10 the dedicated log function is used. If base is zero, infinite, NaN, or negative, NaN is returned.

Parameters:
d a double value greater than 0.0.
base a double value greater than 0.0.
Returns:
the value logbase d

static long j2meClient.J2MEDouble.log10 ( long  d  )  [static]

Returns the base 10 logarithm of a double value.

Parameters:
d a double value greater than 0.0.
Returns:
the value log10 d

static long j2meClient.J2MEDouble.log1p ( long  d  )  [static]

Returns the natural logarithm of 1 + d, computed in a way that is accurate even when the value of d is close to zero.

Parameters:
d a double value greater than -1.0.
Returns:
the value ln d, the natural logarithm of d + 1.
See also:
log(long)

expm1(long)

static long j2meClient.J2MEDouble.longToDouble ( long  x  )  [static]

Convert the given long to a double as would happen in a casting operation specified by section 5.1.2 of the JLS.

This is a widening primitive conversion which will not result in a loss of magnitude, but might result in a loss of precision.

Parameters:
x the long to be converted
Returns:
the double representation of the argument

static long j2meClient.J2MEDouble.longValue ( long  d  )  [static]

Convert the given double to a long as would happen in a casting operation specified by section 5.1.3 of the JLS.

This is a narrowing primitive conversion which may result in a loss of magnitude and/or precision.

Parameters:
d the double to be converted
Returns:
the long representation of the argument

static boolean j2meClient.J2MEDouble.lt ( long  d1,
long  d2 
) [static]

Returns true if the first argument is considered less than the second argument according to section 15.20.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is false
  • Positive zero and negative zero are considered equal
  • Negative infinity is conisdered less than all other values except NaN
  • Positive infinity is conisdered greater than all other values except NaN

This method takes the place of the < operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the first value is less than the second value; false otherwise.

static long j2meClient.J2MEDouble.mod ( long  d1,
long  d2 
) [static]

Returns the remainder of the two double arguments according to section 15.17.3 of the JLS.

This method takes the place of the % operator.

Parameters:
d1 the double dividend
d2 the double divisor
Returns:
the remainder of the two arguments
See also:
IEEEremainder(long, long)

static long j2meClient.J2MEDouble.mul ( long  d1,
long  d2 
) [static]

Returns the product of the two double arguments according to section 15.17.1 of the JLS.

This method takes the place of the * operator.

Parameters:
d1 the first double value
d2 the second double value
Returns:
the product of the two arguments

static boolean j2meClient.J2MEDouble.ne ( long  d1,
long  d2 
) [static]

Returns true if the specified numbers are considered unequal according to section 15.21.1 of the JLS.

Special cases:

  • If either operand is NaN, then the result is true
  • Positive zero and negative zero are considered equal
The value returned by ne is always the opposite of the value returned by eq for the same arguments.

This method takes the place of the != operator.

Parameters:
d1 the first double value to be compared.
d2 the second double value to be compared.
Returns:
true if the two values are considered equal; false otherwise.

static long j2meClient.J2MEDouble.negate ( long  d  )  [static]

Returns the negation of a double value.

Special cases:

  • If the argument is negative zero, the result is positive zero.
  • If the argument is positive zero, the result is negative zero.
  • If the argument is negative infinity, the result is positive infinity.
  • If the argument is positive infinity, the result is negative infinity.
  • If the argument is NaN, the result is NaN.

This method takes the place of the unary - operator.

Parameters:
d the double value whose negated value is to be determined
Returns:
the negation of the argument.

static long j2meClient.J2MEDouble.parseDouble ( String  s  )  [static]

Mimics Double.parseDouble(String).

See the notes on toString for some caveats on String conversion.

See also:
toString
Exceptions:
NumberFormatException if the string does not contain a parsable number.

static long j2meClient.J2MEDouble.percentChange ( long  d1,
long  d2 
) [static]

Returns the difference of d2 and d1, expressed as a percentage of d1.

Parameters:
d1 the "starting" value
d2 the "final" value
Returns:
100 * ((d2 - d1) / d1)

static long j2meClient.J2MEDouble.percentTotal ( long  d1,
long  d2 
) [static]

Returns d2 expressed as a percentage of d1.

Parameters:
d1 the "base" value
d2 the other value
Returns:
100 * (d2 / d1)

static long j2meClient.J2MEDouble.permutations ( long  d1,
long  d2 
) [static]

Return the number of ways of obtaining an ordered subset of d2 elements from a set of d1 elements.

If d1 and d2 are not mathematical integers than or equal to zero, or if d1 is less than d2, the return value is NaN.

Parameters:
d1 a double value
d2 a double value
Returns:
d1! / (d1 - d2)!
See also:
factorial(long)

combinations(long, long)

static long j2meClient.J2MEDouble.scalbn ( long  d,
int  n 
) [static]

Returns the value of the first argument, multiplied by 2 raised to the power of the second argument.

Note that the second argument is really an int, not a float or double.

Parameters:
d a double value.
n an int value.
Returns:
the value d * 2n.

static short j2meClient.J2MEDouble.shortValue ( long  d  )  [static]

Convert the given double to a short as would happen in a casting operation specified by section 5.1.3 of the JLS.

This is a narrowing primitive conversion which may result in a loss of magnitude and/or precision.

Note that this is a non-intuitive conversion. If the argument is outside of the range of the short type, the result is basically meaningless.

Parameters:
d the double to be converted
Returns:
the short representation of the argument

static long j2meClient.J2MEDouble.sinh ( long  d  )  [static]

Returns the hyperbolic sine of an angle.

Parameters:
d an angle, in radians.
Returns:
the hyperbolic sine of the argument.

static long j2meClient.J2MEDouble.sub ( long  d1,
long  d2 
) [static]

Returns the difference of the two double arguments according to section 15.18.2 of the JLS.

This method takes the place of the binary - operator.

Parameters:
d1 the first double value
d2 the second double value
Returns:
the difference of the two arguments

static long j2meClient.J2MEDouble.tanh ( long  d  )  [static]

Returns the hyperbolic tangent of an angle.

Parameters:
d an angle, in radians.
Returns:
the hyperbolic tangent of the argument.

String j2meClient.J2MEDouble.toString (  ) 

Returns a String object representing this J2MEDouble's value.

Equivalent to toString(doubleValue()).

See also:
toString(long)

static String j2meClient.J2MEDouble.toString ( long  d,
int  maxStringLength 
) [static]

Returns a string representation of the double argument, rounded so that the returned String is no longer than maxStringLength characters (or 9 characters, if maxStringLength is less than 9).

Parameters:
d the double to be converted.
maxStringLength the maximum length of the returned string
Returns:
a string representation of the argument.
See also:
toString(long)

static String j2meClient.J2MEDouble.toString ( long  d  )  [static]

Mimics Double.toString(double).

String conversion is a bit of a gray area. The J2SE implementation of this function (Double.toString(double) has some problems. Often times it does not return the shortest valid String, even though it claims to do so, and it has a few corner cases where it behaves oddly (e.g. 0.001 gets converted to the String "0.0010").

The implementation in J2MEDouble uses a much simpler table-based algorithm. It frequently returns slightly different results than Double.toString(double). Sometimes the results are better, and sometimes worse. Ususally the difference is confined to the last character, which may be different or missing in one of the results.

static long j2meClient.J2MEDouble.truncate ( long  d  )  [static]

Returns the double of greatest magnitude (furthest from zero) that is equal to a mathematical integer and which has a mignitude not greater than the argument's magnitude.

Special cases:

  • If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
  • If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Parameters:
d a double value.
Returns:
the double of greatest magnitude (furthest from zero) whose magnitude is not greater than the argument's and which is equal to a mathematical integer.