Java教程

Java 源码 - Double

本文主要是介绍Java 源码 - Double,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

介绍

The Double class wraps a value of the primitive type double in an object.

示例

public class Test {
  public static void main(String[] args) {
    Double d = Double.valueOf("0.123");
    System.out.println(d);
  }
}

源码

public final class Double extends Number implements Comparable<Double> {

  public static String toString(double d) {
    return FloatingDecimal.toJavaFormatString(d);
  }

  public static double parseDouble(String s) throws NumberFormatException {
    return FloatingDecimal.parseDouble(s);
  }

  public static boolean isNaN(double v) {
    return (v != v);
  }

  public static boolean isInfinite(double v) {
    return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
  }

  public static boolean isFinite(double d) {
    return Math.abs(d) <= DoubleConsts.MAX_VALUE;
  }

  private final double value;

  public Double(double value) {
    this.value = value;
  }

  public Double(String s) throws NumberFormatException {
    value = parseDouble(s);
  }
}
这篇关于Java 源码 - Double的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!