* Makefile.in (dbxout.o): Depend on ggc.h.
[official-gcc.git] / libjava / java / lang / Double.java
blob850aa5ad979e0c166b8f4a57fa1cc262e9ba9e1c
1 /* Copyright (C) 1998, 1999 Cygnus Solutions
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
7 details. */
9 package java.lang;
11 /**
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;
33 private double value;
35 private native static double doubleValueOf (String s)
36 throws NumberFormatException;
38 public Double (double v)
40 value = 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)
55 if (obj == null)
56 return false;
58 if (!(obj instanceof Double))
59 return false;
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 ()
74 return (int) value;
77 public long longValue ()
79 return (long) value;
82 public float floatValue ()
84 return (float) value;
87 public double doubleValue ()
89 return value;
92 public byte byteValue ()
94 return (byte) value;
97 public short shortValue ()
99 return (short) value;
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
112 if (s == null)
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);