]>
gcc.gnu.org Git - gcc.git/blob - libjava/java/lang/Double.java
fdcd4202729fa8796639ff00c6426ba3ea3f3e74
1 /* Copyright (C) 1998, 1999 Red Hat, Inc.
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 * @author Andrew Haley <aph@cygnus.com>
13 * @date September 25, 1998.
15 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
16 * "The Java Language Specification", ISBN 0-201-63451-1
17 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
18 * Status: Believed complete and correct.
21 public final class Double
extends Number
23 public static final double MIN_VALUE
= 5e-324;
24 public static final double MAX_VALUE
= 1.7976931348623157e+308;
25 public static final double NEGATIVE_INFINITY
= -1.0d
/0.0d
;
26 public static final double POSITIVE_INFINITY
= 1.0d
/0.0d
;
27 public static final double NaN
= 0.0d
/0.0d
;
29 // This initialization is seemingly circular, but it is accepted
30 // by javac, and is handled specially by gcc.
31 public static final Class TYPE
= double.class;
35 private native static double doubleValueOf (String s
)
36 throws NumberFormatException
;
38 public Double (double v
)
43 public Double (String s
) throws NumberFormatException
45 value
= valueOf (s
).doubleValue ();
48 public String
toString ()
50 return toString (value
);
53 public boolean equals (Object obj
)
58 if (!(obj
instanceof Double
))
61 Double d
= (Double
) obj
;
63 return doubleToLongBits (value
) == doubleToLongBits (d
.doubleValue ());
66 public int hashCode ()
68 long v
= doubleToLongBits (value
);
69 return (int) (v ^
(v
>>> 32));
72 public int intValue ()
77 public long longValue ()
82 public float floatValue ()
87 public double doubleValue ()
92 public byte byteValue ()
97 public short shortValue ()
102 native static String
toString (double v
, boolean isFloat
);
104 public static String
toString (double v
)
106 return toString (v
, false);
109 public static Double
valueOf (String s
) throws NullPointerException
,
110 NumberFormatException
113 throw new NullPointerException ();
115 return new Double (doubleValueOf (s
));
118 public boolean isNaN ()
120 return isNaN (value
);
123 public static boolean isNaN (double v
)
125 long bits
= doubleToLongBits (v
);
126 long e
= bits
& 0x7ff0000000000000L
;
127 long f
= bits
& 0x000fffffffffffffL
;
129 return e
== 0x7ff0000000000000L
&& f
!= 0L;
132 public boolean isInfinite ()
134 return isInfinite (value
);
137 public static boolean isInfinite (double v
)
139 long bits
= doubleToLongBits (v
);
140 long f
= bits
& 0x7fffffffffffffffL
;
142 return f
== 0x7ff0000000000000L
;
145 public static native long doubleToLongBits (double value
);
147 public static native double longBitsToDouble (long bits
);
This page took 0.041897 seconds and 4 git commands to generate.