SpecZone .ru
спецификации, руководства, описания, API

java.lang.Double
public final classDouble
extends Number { public static final doubleMIN_VALUE
=
5e324; public static final doubleMAX_VALUE
= 1.7976931348623157e+308; public static final doubleNEGATIVE_INFINITY
= 1.0/0.0; public static final doublePOSITIVE_INFINITY
= 1.0/0.0; public static final doubleNaN
= 0.0/0.0; publicDouble
(double value); publicDouble
(String s)
throws NumberFormatException; public StringtoString
(); public booleanequals
(Object obj); public inthashCode
(); public intintValue
(); public longlongValue
(); public floatfloatValue
(); public doubledoubleValue
(); public static StringtoString
(double d); public static DoublevalueOf
(String s)
throws NullPointerException, NumberFormatException; public booleanisNaN
(); public static booleanisNaN
(double v); public booleanisInfinite
(); public static booleanisInfinite
(double v); public static longdoubleToLongBits
(double value); public static doublelongBitsToDouble
(long bits); }
20.10.1 public static final double
MIN_VALUE
= 5e324;
The constant value of this field is the smallest positive nonzero value of type
double
. It is equal to the value returned by Double.longBitsToDouble(0x1L)
.
20.10.2 public static final double
MAX_VALUE
= 1.7976931348623157e+308;
The constant value of this field is the largest positive finite value of type double
.
It is equal to the returned by:
Double.longBitsToDouble(0x7fefffffffffffffL)
20.10.3 public static final double
NEGATIVE_INFINITY
= 1.0/0.0;
The constant value of this field is the negative infinity of type double
. It is equal
to the value returned by Double.longBitsToDouble(0xfff0000000000000L)
.
20.10.4 public static final double
POSITIVE_INFINITY
= 1.0/0.0;
The constant value of this field is the positive infinity of type double
. It is equal to
the value returned by Double.longBitsToDouble(0x7ff0000000000000L)
.
20.10.5 public static final double
NaN
= 0.0/0.0;
The constant value of this field is the NotaNumber of type double
. It is equal to
the value returned by Double.longBitsToDouble(0x7ff8000000000000L)
.
20.10.6 public
Double
(double value)
This constructor initializes a newly created Double
object so that it represents the
primitive value that is the argument.
20.10.7 public
Double
(String s)
throws NumberFormatException
This constructor initializes a newly created Double
object so that it represents the
floatingpoint value of type double
represented by the string. The string is converted
to a double
value in exactly the manner used by the valueOf
method
(§20.9.17).
20.10.8 public String
toString
()
The primitive double
value represented by this Double
object is converted to a
string exactly as if by the method toString
of one argument (§20.10.15).
Overrides the toString
method of Object
(§20.1.2).
20.10.9 public boolean
equals
(Object obj)
The result is true
if and only if the argument is not null
and is a Double
object
that represents the same double
value as this Double
object. For this purpose,
two double
values are considered to be the same if and only if the method
doubleToLongBits
(§20.10.21) returns the same long
value when applied to
each. Note that even though the ==
operator returns false
if both operands are
NaN, this equals
method will return true
if this Double
object and the argument
are both Double
objects that represent NaN. On the other hand, even though the
==
operator returns true
if one operand is positive zero and the other is negative
zero, this equals
method will return false
if this Double
object and the argument
represent zeroes of different sign. This allows hashtables to operate properly.
Overrides the equals
method of Object
(§20.1.3).
20.10.10 public int
hashCode
()
The result is the exclusive OR of the two halves of the long integer bit representation,
exactly as produced by the method doubleToLongBits
(§20.10.21), of the
primitive double
value represented by this Double
object. That is, the hashcode is
the value of the expression:
(int)(v^(v>>>32))where
v
is defined by:
long v = Double.doubleToLongBits(this.longValue());Overrides the
hashCode
method of Object
(§20.1.4).20.10.11 public int
intValue
()
The double
value represented by this Double
object is converted (§5.1.3) to type
int
and the result of the conversion is returned.
Overrides the intValue
method of Number
(§20.6.1).
20.10.12 public long
longValue
()
The double
value represented by this Double
object is converted (§5.1.3) to type
long
and the result of the conversion is returned.
Overrides the longValue
method of Number
(§20.6.2).
20.10.13 public float
floatValue
()
The double
value represented by this Double
object is converted (§5.1.3) to type
float
and the result of the conversion is returned.
Overrides the floatValue
method of Number
(§20.6.3).
20.10.14 public double
doubleValue
()
The double
value represented by this Double
object is returned.
Overrides the doubleValue
method of Number
(§20.6.4).
20.10.15 public static String
toString
(double d)
The argument is converted to a readable string format as follows. All characters mentioned below are ASCII characters.
"NaN"
.
''
('\u002d'
); if the sign is positive, no sign character appears in the result. As for the magnitude m:
"Infinity"
; thus, positive infinity produces the result "Infinity"
and negative infinity produces the result "Infinity"
.
"0.0"
; thus, negative zero produces the result "0.0"
and positive zero produces the result "0.0"
.
'.'
(\u002E
), followed by one or more decimal digits representing the fractional part of m.
'.'
(\u002E
), followed by decimal digits representing the fractional part of a, followed by the letter 'E'
(\u0045
), followed by a representation of n as a decimal integer, as produced by the method Integer.toString
of one argument (§20.7.12).
double
. That is, suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument d. Then d must be the double
value nearest to x; or if two double
values are equally close to x, then d must be one of them and the least significant bit of the significand of d must be 0
.
[This specification for the method toString
is scheduled for introduction in Java version 1.1. In previous versions of Java, this method produces Inf
instead of Infinity
for infinite values. Also, it rendered finite values in the same form as the %g
format of the printf
function in the C programming language, which can lose information because it produces at most six digits after the decimal point.]
20.10.16 public static Double
valueOf
(String s)
throws NullPointerException, NumberFormatException
The string s
is interpreted as the representation of a floatingpoint value and a
Double
object representing that value is created and returned.
If s
is null
, then a NullPointerException
is thrown.
Leading and trailing whitespace (§20.5.19) characters in s
are ignored. The rest of s
should constitute a FloatValue as described by the lexical syntax rule:
FloatValue:where Sign, Digits, and ExponentPart are as defined in §3.10.2. If it does not have the form of a FloatValue, then a
Sign_{opt} Digits.
Digits_{opt}ExponentPart_{opt } Sign_{opt}
.
DigitsExponentPart_{opt }
NumberFormatException
is thrown. Otherwise,
it is regarded as representing an exact decimal value in the usual "computerized
scientific notation"; this exact decimal value is then conceptually converted to an
"infinitely precise" binary value that is then rounded to type double
by the usual
roundtonearest rule of IEEE 754 floatingpoint arithmetic. Finally, a new object
of class Double
is created to represent the double
value.
Note that neither D
nor d
is permitted to appear in s
as a type indicator, as would be permitted in Java source code (§3.10.1).
20.10.17 public boolean
isNaN
()
The result is true
if and only if the value represented by this Double
object is
NaN.
20.10.18 public static boolean
isNaN
(double v)
The result is true
if and only if the value of the argument is NaN.
20.10.19 public boolean
isInfinite
()
The result is true
if and only if the value represented by this Double
object is
positive infinity or negative infinity.
20.10.20 public static boolean
isInfinite
(double v)
The result is true
if and only if the value of the argument is positive infinity or
negative infinity.
20.10.21 public static long
doubleToLongBits
(double value)
The result is a representation of the floatingpoint argument according to the IEEE 754 floatingpoint "double format" bit layout:
0x8000000000000000L
) represents the sign of the floatingpoint number.
0x7ff0000000000000L
) represent the exponent.
0x000fffffffffffffL
) represent the significand (sometimes called the mantissa) of the floatingpoint number.
0x7ff0000000000000L
.
0xfff0000000000000L
.
0x7ff8000000000000L
.
long
integer that, when given to the longBitsToDouble
method (§20.10.22), will produce a floatingpoint value equal to the argument to doubleToLongBits
.20.10.22 public static double
longBitsToDouble
(long bits)
The argument is considered to be a representation of a floatingpoint value according to the IEEE 754 floatingpoint "double format" bit layout. That floatingpoint value is returned as the result.
0x7f80000000000000L
, the result will be positive infinity.
0xff80000000000000L
, the result will be negative infinity.
0x7ff0000000000001L
through 0x7fffffffffffffffL
or in the range 0xfff0000000000001L
through 0xffffffffffffffffL
, the result will be NaN. (All IEEE 754 NaN values are, in effect, lumped together by the Java language into a single value called NaN.)
int s = ((bits >> 63) == 0) ? 1 : 1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) ? (bits & 0xfffffffffffffL) << 1 : (bits & 0xfffffffffffffL)  0x10000000000000L;Then the floatingpoint result equals the value of the mathematical expression .
Contents  Prev  Next  Index
Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com