| Method from java.lang.Double Detail: |
public byte byteValue() {
return (byte) value;
}
|
public static int compare(double double1,
double double2) {
// Non-zero, non-NaN checking.
if (double1 > double2) {
return 1;
}
if (double2 > double1) {
return -1;
}
if (double1 == double2 && 0.0d != double1) {
return 0;
}
// NaNs are equal to other NaNs and larger than any other double
if (isNaN(double1)) {
if (isNaN(double2)) {
return 0;
}
return 1;
} else if (isNaN(double2)) {
return -1;
}
// Deal with +0.0 and -0.0
long d1 = doubleToRawLongBits(double1);
long d2 = doubleToRawLongBits(double2);
// The below expression is equivalent to:
// (d1 == d2) ? 0 : (d1 < d2) ? -1 : 1
return (int) ((d1 > > 63) - (d2 > > 63));
}
Compares the two specified double values. There are two special cases:
- {@code Double.NaN} is equal to {@code Double.NaN} and it is greater
than any other double value, including {@code Double.POSITIVE_INFINITY};
- +0.0d is greater than -0.0d
|
public int compareTo(Double object) {
return compare(value, object.value);
}
Compares this object to the specified double object to determine their
relative order. There are two special cases:
- {@code Double.NaN} is equal to {@code Double.NaN} and it is greater
than any other double value, including {@code Double.POSITIVE_INFINITY};
- +0.0d is greater than -0.0d
|
public static native long doubleToLongBits(double value)
Converts the specified double value to a binary representation conforming
to the IEEE 754 floating-point double precision bit layout. All
Not-a-Number (NaN) values are converted to a single NaN
representation ({@code 0x7ff8000000000000L}). |
public static native long doubleToRawLongBits(double value)
Converts the specified double value to a binary representation conforming
to the IEEE 754 floating-point double precision bit layout.
Not-a-Number (NaN) values are preserved. |
public double doubleValue() {
return value;
}
Gets the primitive value of this double. |
public boolean equals(Object object) {
return (object == this)
|| (object instanceof Double)
&& (doubleToLongBits(this.value) == doubleToLongBits(((Double) object).value));
}
Compares this object with the specified object and indicates if they are
equal. In order to be equal, {@code object} must be an instance of
{@code Double} and the bit pattern of its double value is the same as
this object's. |
public float floatValue() {
return (float) value;
}
|
public int hashCode() {
long v = doubleToLongBits(value);
return (int) (v ^ (v > > > 32));
}
|
public int intValue() {
return (int) value;
}
|
public boolean isInfinite() {
return isInfinite(value);
}
Indicates whether this object represents an infinite value. |
public static boolean isInfinite(double d) {
return (d == POSITIVE_INFINITY) || (d == NEGATIVE_INFINITY);
}
Indicates whether the specified double represents an infinite value. |
public boolean isNaN() {
return isNaN(value);
}
Indicates whether this object is a Not-a-Number (NaN) value. |
public static boolean isNaN(double d) {
return d != d;
}
Indicates whether the specified double is a Not-a-Number (NaN)
value. |
public static native double longBitsToDouble(long bits)
Converts the specified IEEE 754 floating-point double precision bit
pattern to a Java double value. |
public long longValue() {
return (long) value;
}
|
public static double parseDouble(String string) throws NumberFormatException {
return org.apache.harmony.luni.util.FloatingPointParser
.parseDouble(string);
}
Parses the specified string as a double value. |
public short shortValue() {
return (short) value;
}
|
public static String toHexString(double d) {
/*
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
if (d != d) {
return "NaN"; //$NON-NLS-1$
}
if (d == POSITIVE_INFINITY) {
return "Infinity"; //$NON-NLS-1$
}
if (d == NEGATIVE_INFINITY) {
return "-Infinity"; //$NON-NLS-1$
}
long bitValue = doubleToLongBits(d);
boolean negative = (bitValue & 0x8000000000000000L) != 0;
// mask exponent bits and shift down
long exponent = (bitValue & 0x7FF0000000000000L) > > > 52;
// mask significand bits and shift up
long significand = bitValue & 0x000FFFFFFFFFFFFFL;
if (exponent == 0 && significand == 0) {
return (negative ? "-0x0.0p0" : "0x0.0p0"); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuilder hexString = new StringBuilder(10);
if (negative) {
hexString.append("-0x"); //$NON-NLS-1$
} else {
hexString.append("0x"); //$NON-NLS-1$
}
if (exponent == 0) { // denormal (subnormal) value
hexString.append("0."); //$NON-NLS-1$
// significand is 52-bits, so there can be 13 hex digits
int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
while ((significand != 0) && ((significand & 0xF) == 0)) {
significand > > >= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
String hexSignificand = Long.toHexString(significand);
// if there are digits left, then insert some '0' chars first
if (significand != 0 && fractionDigits > hexSignificand.length()) {
int digitDiff = fractionDigits - hexSignificand.length();
while (digitDiff-- != 0) {
hexString.append('0');
}
}
hexString.append(hexSignificand);
hexString.append("p-1022"); //$NON-NLS-1$
} else { // normal value
hexString.append("1."); //$NON-NLS-1$
// significand is 52-bits, so there can be 13 hex digits
int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
while ((significand != 0) && ((significand & 0xF) == 0)) {
significand > > >= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
String hexSignificand = Long.toHexString(significand);
// if there are digits left, then insert some '0' chars first
if (significand != 0 && fractionDigits > hexSignificand.length()) {
int digitDiff = fractionDigits - hexSignificand.length();
while (digitDiff-- != 0) {
hexString.append('0');
}
}
hexString.append(hexSignificand);
hexString.append('p');
// remove exponent's 'bias' and convert to a string
hexString.append(Long.toString(exponent - 1023));
}
return hexString.toString();
}
Converts the specified double into its hexadecimal string representation. |
public String toString() {
return Double.toString(value);
}
|
public static String toString(double d) {
return org.apache.harmony.luni.util.NumberConverter.convert(d);
}
Returns a string containing a concise, human-readable description of the
specified double value. |
public static Double valueOf(String string) throws NumberFormatException {
return new Double(parseDouble(string));
}
Parses the specified string as a double value. |
public static Double valueOf(double d) {
return new Double(d);
}
Returns a {@code Double} instance for the specified double value. |