home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / lang / Double.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  3.6 KB  |  152 lines

  1. package java.lang;
  2.  
  3. import sun.misc.FloatingDecimal;
  4. import sun.misc.FpUtils;
  5.  
  6. public final class Double extends Number implements Comparable<Double> {
  7.    public static final double POSITIVE_INFINITY = (double)Float.POSITIVE_INFINITY;
  8.    public static final double NEGATIVE_INFINITY = (double)Float.NEGATIVE_INFINITY;
  9.    public static final double NaN = NaN;
  10.    public static final double MAX_VALUE = 1.7976931348623157E308;
  11.    public static final double MIN_NORMAL = 2.2250738585072014E-308;
  12.    public static final double MIN_VALUE = 4.9E-324;
  13.    public static final int MAX_EXPONENT = 1023;
  14.    public static final int MIN_EXPONENT = -1022;
  15.    public static final int SIZE = 64;
  16.    public static final Class<Double> TYPE = Class.getPrimitiveClass("double");
  17.    private final double value;
  18.    private static final long serialVersionUID = -9172774392245257468L;
  19.  
  20.    public static String toString(double var0) {
  21.       return (new FloatingDecimal(var0)).toJavaFormatString();
  22.    }
  23.  
  24.    public static String toHexString(double var0) {
  25.       if (!FpUtils.isFinite(var0)) {
  26.          return toString(var0);
  27.       } else {
  28.          StringBuffer var2 = new StringBuffer(24);
  29.          if (FpUtils.rawCopySign((double)1.0F, var0) == (double)-1.0F) {
  30.             var2.append("-");
  31.          }
  32.  
  33.          var2.append("0x");
  34.          var0 = Math.abs(var0);
  35.          if (var0 == (double)0.0F) {
  36.             var2.append("0.0p0");
  37.          } else {
  38.             boolean var3 = var0 < MIN_NORMAL;
  39.             long var4 = doubleToLongBits(var0) & 4503599627370495L | 1152921504606846976L;
  40.             var2.append(var3 ? "0." : "1.");
  41.             String var6 = Long.toHexString(var4).substring(3, 16);
  42.             var2.append(var6.equals("0000000000000") ? "0" : var6.replaceFirst("0{1,12}$", ""));
  43.             var2.append("p" + (var3 ? -1022 : FpUtils.getExponent(var0)));
  44.          }
  45.  
  46.          return var2.toString();
  47.       }
  48.    }
  49.  
  50.    public static Double valueOf(String var0) throws NumberFormatException {
  51.       return new Double(FloatingDecimal.readJavaFormatString(var0).doubleValue());
  52.    }
  53.  
  54.    public static Double valueOf(double var0) {
  55.       return new Double(var0);
  56.    }
  57.  
  58.    public static double parseDouble(String var0) throws NumberFormatException {
  59.       return FloatingDecimal.readJavaFormatString(var0).doubleValue();
  60.    }
  61.  
  62.    public static boolean isNaN(double var0) {
  63.       return var0 != var0;
  64.    }
  65.  
  66.    public static boolean isInfinite(double var0) {
  67.       return var0 == POSITIVE_INFINITY || var0 == NEGATIVE_INFINITY;
  68.    }
  69.  
  70.    public Double(double var1) {
  71.       this.value = var1;
  72.    }
  73.  
  74.    public Double(String var1) throws NumberFormatException {
  75.       this(valueOf(var1));
  76.    }
  77.  
  78.    public boolean isNaN() {
  79.       return isNaN(this.value);
  80.    }
  81.  
  82.    public boolean isInfinite() {
  83.       return isInfinite(this.value);
  84.    }
  85.  
  86.    public String toString() {
  87.       return String.valueOf(this.value);
  88.    }
  89.  
  90.    public byte byteValue() {
  91.       return (byte)((int)this.value);
  92.    }
  93.  
  94.    public short shortValue() {
  95.       return (short)((int)this.value);
  96.    }
  97.  
  98.    public int intValue() {
  99.       return (int)this.value;
  100.    }
  101.  
  102.    public long longValue() {
  103.       return (long)this.value;
  104.    }
  105.  
  106.    public float floatValue() {
  107.       return (float)this.value;
  108.    }
  109.  
  110.    public double doubleValue() {
  111.       return this.value;
  112.    }
  113.  
  114.    public int hashCode() {
  115.       long var1 = doubleToLongBits(this.value);
  116.       return (int)(var1 ^ var1 >>> 32);
  117.    }
  118.  
  119.    public boolean equals(Object var1) {
  120.       return var1 instanceof Double && doubleToLongBits(((Double)var1).value) == doubleToLongBits(this.value);
  121.    }
  122.  
  123.    public static long doubleToLongBits(double var0) {
  124.       long var2 = doubleToRawLongBits(var0);
  125.       if ((var2 & 9218868437227405312L) == 9218868437227405312L && (var2 & 4503599627370495L) != 0L) {
  126.          var2 = 9221120237041090560L;
  127.       }
  128.  
  129.       return var2;
  130.    }
  131.  
  132.    public static native long doubleToRawLongBits(double var0);
  133.  
  134.    public static native double longBitsToDouble(long var0);
  135.  
  136.    public int compareTo(Double var1) {
  137.       return compare(this.value, var1.value);
  138.    }
  139.  
  140.    public static int compare(double var0, double var2) {
  141.       if (var0 < var2) {
  142.          return -1;
  143.       } else if (var0 > var2) {
  144.          return 1;
  145.       } else {
  146.          long var4 = doubleToLongBits(var0);
  147.          long var6 = doubleToLongBits(var2);
  148.          return var4 == var6 ? 0 : (var4 < var6 ? -1 : 1);
  149.       }
  150.    }
  151. }
  152.