Java : Double (倍精度浮動小数点数) - API使用例
Double (Java SE 18 & JDK 18) の使用例まとめです。
だいたいのメソッドを網羅済みです。
API仕様のおともにどうぞ。
概要
Doubleは、プリミティブ型 double のラッパークラスです。
倍精度の浮動小数点数を扱います。
double は Object ではないので、そのままでは List などのコレクションに追加できません。
そんなときは、 Doubleクラスで double をラップすると追加が可能となります。
// コンパイルエラー
final var list = new ArrayList<double>();
// コンパイルOK
final var list = new ArrayList<Double>();
list.add(1.11);
list.add(2.22);
list.add(3.33);
System.out.println(list); // [1.11, 2.22, 3.33]
他には、
- double の非数値(NaN)、負の無限大値(NEGATIVE_INFINITY)、正の無限大値(POSITIVE_INFINITY)
- 文字列から double への変換 (parseDouble)
などなど、浮動小数点数に関するメソッドがそろっています。
関連記事
フィールド
static final int BYTES
System.out.println(Double.BYTES); // 8
static final int MAX_EXPONENT
System.out.println(Double.MAX_EXPONENT); // 1023
static final double MAX_VALUE
// 1.7976931348623157E308
System.out.println(Double.MAX_VALUE);
// 179769313486231570814527423731704356798070567525844996598917
// 476803157260780028538760589558632766878171540458953514382464
// 234321326889464182768467546703537516986049910576551282076245
// 490090389328944075868508455133942304583236903222948165808559
// 332123348274797826204144723168738177180919299881250404026184
// 124858368
System.out.println(new BigDecimal(Double.MAX_VALUE).toPlainString());
static final int MIN_EXPONENT
System.out.println(Double.MIN_EXPONENT); // -1022
static final double MIN_NORMAL
// 2.2250738585072014E-308
System.out.println(Double.MIN_NORMAL);
// 0.0000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000222507385850720138309023271733240406421921598046233
// 183055332741688720443481391819585428315901251102056406733973
// 103581100515243416155346010885601238537771882113077799353200
// 233047961014744258363607192156504694250373420837525080665061
// 665815894872049117996859163964850063590877011830487479978088
// 775374994945158045160505091539985658247081864511353793580499
// 211598108576605199243335211435239014879569960959128889160299
// 264151106346631339366347758651302937176204732563178148566435
// 087212282863764204484681140761391147706280168985324411002416
// 144742161856716615054015428508471675290190316132277889672970
// 737312333408698898317506783884692609277397797285865965494109
// 136909540613646756870239867831529068098461721092462539672851
// 5625
System.out.println(new BigDecimal(Double.MIN_NORMAL).toPlainString());
static final double MIN_VALUE
// 4.9E-324
System.out.println(Double.MIN_VALUE);
// 0.0000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000000000000000000000000000000000000000
// 000000000000000000000000049406564584124654417656879286822137
// 236505980261432476442558568250067550727020875186529983636163
// 599237979656469544571773092665671035593979639877479601078187
// 812630071319031140452784581716784898210368871863605699873072
// 305000638740915356498438731247339727316961514003171538539807
// 412623856559117102665855668676818703956031062493194527159149
// 245532930545654440112748012970999954193198940908041656332452
// 475714786901472678015935523861155013480352649347201937902681
// 071074917033322268447533357208324319360923828934583680601060
// 115061698097530783422773183292479049825247307763759272478746
// 560847782037344696995336470179726777175851256605511991315048
// 911014510378627381672509558373897335989936648099411642057026
// 37090279242767544565229087538682506419718265533447265625
System.out.println(new BigDecimal(Double.MIN_VALUE).toPlainString());
static final double NaN
System.out.println(Double.NaN); // NaN
static final double NEGATIVE_INFINITY
System.out.println(Double.NEGATIVE_INFINITY); // -Infinity
static final double POSITIVE_INFINITY
System.out.println(Double.POSITIVE_INFINITY); // Infinity
static final int SIZE
System.out.println(Double.SIZE); // 64
static final Class<Double> TYPE
System.out.println(Double.TYPE.getName()); // double
System.out.println(Double.TYPE.isPrimitive()); // true
コンストラクタ
Double (double value)
非推奨です。
代わりに valueOf(double d) を使います。
Double (String s)
非推奨です。
代わりに valueOf(String s) を使います。
メソッド
byte byteValue ()
final byte value1 = Double.valueOf(100.0).byteValue();
System.out.println(value1); // 100
final byte value2 = Double.valueOf(22.222).byteValue();
System.out.println(value2); // 22
final byte value3 = Double.valueOf(9.99).byteValue();
System.out.println(value3); // 9
System.out.println(Byte.MAX_VALUE); // 127
System.out.println(Byte.MIN_VALUE); // -128
final byte value1 = Double.valueOf(127.0).byteValue();
System.out.println(value1); // 127
final byte value2 = Double.valueOf(128.0).byteValue();
System.out.println(value2); // -128
final byte value3 = Double.valueOf(-128.0).byteValue();
System.out.println(value3); // -128
final byte value4 = Double.valueOf(-129.0).byteValue();
System.out.println(value4); // 127
final byte value1 = Double.valueOf(Double.NaN).byteValue();
System.out.println(value1); // 0
final byte value2 = Double.valueOf(Double.NEGATIVE_INFINITY).byteValue();
System.out.println(value2); // 0
final byte value3 = Double.valueOf(Double.POSITIVE_INFINITY).byteValue();
System.out.println(value3); // -1
static int compare (double d1, double d2)
System.out.println(Double.compare(1.23, 4.56)); // -1
System.out.println(Double.compare(4.56, 1.23)); // 1
System.out.println(Double.compare(1.23, -1.23)); // 1
System.out.println(Double.compare(-1.23, 1.23)); // -1
System.out.println(Double.compare(0.0, -0.0)); // 1
System.out.println(Double.compare(-0.0, 0.0)); // -1
System.out.println(Double.compare(Double.NaN, 1.23)); // 1
System.out.println(Double.compare(Double.NEGATIVE_INFINITY, 1.23)); // -1
System.out.println(Double.compare(Double.POSITIVE_INFINITY, 1.23)); // 1
int compareTo (Double anotherDouble)
final var d1 = Double.valueOf(1.23);
final var d2 = Double.valueOf(4.56);
System.out.println(d1.compareTo(d2)); // -1
System.out.println(d2.compareTo(d1)); // 1
final var d1 = Double.valueOf(1.23);
final var d2 = Double.valueOf(-1.23);
System.out.println(d1.compareTo(d2)); // 1
System.out.println(d2.compareTo(d1)); // -1
final var d1 = Double.valueOf(0.0);
final var d2 = Double.valueOf(-0.0);
System.out.println(d1.compareTo(d2)); // 1
System.out.println(d2.compareTo(d1)); // -1
final var d = Double.valueOf(1.23);
System.out.println(d.compareTo(Double.NaN)); // -1
System.out.println(d.compareTo(Double.NEGATIVE_INFINITY)); // 1
System.out.println(d.compareTo(Double.POSITIVE_INFINITY)); // -1
Optional<Double> describeConstable ()
final var ret = Double.valueOf(1.23).describeConstable();
System.out.println(ret); // Optional[1.23]
static long doubleToLongBits (double value)
final var bits1 = Double.doubleToLongBits(1.0);
System.out.println(Long.toHexString(bits1)); // 3ff0000000000000
final var bits2 = Double.doubleToLongBits(-1.0);
System.out.println(Long.toHexString(bits2)); // bff0000000000000
final var bits = Double.doubleToLongBits(123.25);
System.out.println(Long.toHexString(bits)); // 405ed00000000000
final var bits1 = Double.doubleToLongBits(Double.NaN);
System.out.println(Long.toHexString(bits1)); // 7ff8000000000000
final var bits2 = Double.doubleToLongBits(Double.NEGATIVE_INFINITY);
System.out.println(Long.toHexString(bits2)); // fff0000000000000
final var bits3 = Double.doubleToLongBits(Double.POSITIVE_INFINITY);
System.out.println(Long.toHexString(bits3)); // 7ff0000000000000
static long doubleToRawLongBits (double value)
final var bits1 = Double.doubleToRawLongBits(1.0);
System.out.println(Long.toHexString(bits1)); // 3ff0000000000000
final var bits2 = Double.doubleToRawLongBits(-1.0);
System.out.println(Long.toHexString(bits2)); // bff0000000000000
final var bits = Double.doubleToRawLongBits(123.25);
System.out.println(Long.toHexString(bits)); // 405ed00000000000
final var bits1 = Double.doubleToRawLongBits(Double.NaN);
System.out.println(Long.toHexString(bits1)); // 7ff8000000000000
final var bits2 = Double.doubleToRawLongBits(Double.NEGATIVE_INFINITY);
System.out.println(Long.toHexString(bits2)); // fff0000000000000
final var bits3 = Double.doubleToRawLongBits(Double.POSITIVE_INFINITY);
System.out.println(Long.toHexString(bits3)); // 7ff0000000000000
double doubleValue ()
final double ret1 = Double.valueOf(1.23).doubleValue();
System.out.println(ret1); // 1.23
final double ret2 = Double.valueOf(-4.56).doubleValue();
System.out.println(ret2); // -4.56
System.out.println(Double.valueOf(Double.NaN).doubleValue()); // NaN
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).doubleValue()); // -Infinity
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).doubleValue()); // Infinity
boolean equals (Object obj)
final var d1 = Double.valueOf(1.23);
final var d2 = Double.valueOf(1.23);
System.out.println(d1.equals(d2)); // true
final var d1 = Double.valueOf(1.23);
final var d2 = Double.valueOf(4.56);
System.out.println(d1.equals(d2)); // false
// 誤差が発生する例です。
final var d1 = Double.valueOf(0.3);
final var d2 = Double.valueOf(0.1 + 0.2);
System.out.println(d1.equals(d2)); // false
final var d1 = Double.valueOf(Double.NaN);
final var d2 = Double.valueOf(Double.NaN);
System.out.println(d1.doubleValue() == d2.doubleValue()); // false
System.out.println(d1.equals(d2)); // true
final var d1 = Double.valueOf(+0.0);
final var d2 = Double.valueOf(-0.0);
System.out.println(d1.doubleValue() == d2.doubleValue()); // true
System.out.println(d1.equals(d2)); // false
float floatValue ()
final float ret1 = Double.valueOf(1.23).floatValue();
System.out.println(ret1); // 1.23
final float ret2 = Double.valueOf(-4.56).floatValue();
System.out.println(ret2); // -4.56
final var d = Double.valueOf(Double.MAX_VALUE);
System.out.println(d); // 1.7976931348623157E308
final float ret = d.floatValue();
System.out.println(ret); // Infinity
System.out.println(Double.valueOf(Double.NaN).floatValue()); // NaN
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).floatValue()); // -Infinity
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).floatValue()); // Infinity
int hashCode ()
System.out.println(Double.valueOf(1.23).hashCode()); // 1158867386
System.out.println(Double.valueOf(-4.56).hashCode()); // 1673869133
System.out.println(Double.valueOf(Double.MAX_VALUE).hashCode()); // -2146435072
System.out.println(Double.valueOf(Double.MIN_VALUE).hashCode()); // 1
System.out.println(Double.valueOf(Double.NaN).hashCode()); // 2146959360
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).hashCode()); // -1048576
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).hashCode()); // 2146435072
System.out.println(Double.valueOf(+0.0).hashCode()); // 0
System.out.println(Double.valueOf(-0.0).hashCode()); // -2147483648
static int hashCode (double value)
System.out.println(Double.hashCode(1.23)); // 1158867386
System.out.println(Double.hashCode(-4.56)); // 1673869133
System.out.println(Double.hashCode(Double.MAX_VALUE)); // -2146435072
System.out.println(Double.hashCode(Double.MIN_VALUE)); // 1
System.out.println(Double.hashCode(Double.NaN)); // 2146959360
System.out.println(Double.hashCode(Double.NEGATIVE_INFINITY)); // -1048576
System.out.println(Double.hashCode(Double.POSITIVE_INFINITY)); // 2146435072
System.out.println(Double.hashCode(+0.0)); // 0
System.out.println(Double.hashCode(-0.0)); // -2147483648
int intValue ()
final int value1 = Double.valueOf(100.0).intValue();
System.out.println(value1); // 100
final int value2 = Double.valueOf(22.222).intValue();
System.out.println(value2); // 22
final int value3 = Double.valueOf(9.99).intValue();
System.out.println(value3); // 9
System.out.println(Integer.MAX_VALUE); // 2147483647
System.out.println(Integer.MIN_VALUE); // -2147483648
final int value1 = Double.valueOf(2147483647.0).intValue();
System.out.println(value1); // 2147483647
final int value2 = Double.valueOf(2147483648.0).intValue();
System.out.println(value2); // 2147483647
final int value3 = Double.valueOf(-2147483648.0).intValue();
System.out.println(value3); // -2147483648
final int value4 = Double.valueOf(-2147483649.0).intValue();
System.out.println(value4); // -2147483648
final int value1 = Double.valueOf(Double.NaN).intValue();
System.out.println(value1); // 0
final int value2 = Double.valueOf(Double.NEGATIVE_INFINITY).intValue();
System.out.println(value2); // -2147483648
final int value3 = Double.valueOf(Double.POSITIVE_INFINITY).intValue();
System.out.println(value3); // 2147483647
static boolean isFinite (double d)
System.out.println(Double.isFinite(0.0)); // true
System.out.println(Double.isFinite(1.23)); // true
System.out.println(Double.isFinite(-4.56)); // true
System.out.println(Double.isFinite(Double.NaN)); // false
System.out.println(Double.isFinite(Double.NEGATIVE_INFINITY)); // false
System.out.println(Double.isFinite(Double.POSITIVE_INFINITY)); // false
boolean isInfinite ()
System.out.println(Double.valueOf(0.0).isInfinite()); // false
System.out.println(Double.valueOf(1.23).isInfinite()); // false
System.out.println(Double.valueOf(-4.56).isInfinite()); // false
System.out.println(Double.valueOf(Double.NaN).isInfinite()); // false
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).isInfinite()); // true
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).isInfinite()); // true
static boolean isInfinite (double v)
System.out.println(Double.isInfinite(0.0)); // false
System.out.println(Double.isInfinite(1.23)); // false
System.out.println(Double.isInfinite(-4.56)); // false
System.out.println(Double.isInfinite(Double.NaN)); // false
System.out.println(Double.isInfinite(Double.NEGATIVE_INFINITY)); // true
System.out.println(Double.isInfinite(Double.POSITIVE_INFINITY)); // true
boolean isNaN ()
System.out.println(Double.valueOf(0.0).isNaN()); // false
System.out.println(Double.valueOf(1.23).isNaN()); // false
System.out.println(Double.valueOf(-4.56).isNaN()); // false
System.out.println(Double.valueOf(Double.NaN).isNaN()); // true
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).isNaN()); // false
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).isNaN()); // false
static boolean isNaN (double v)
System.out.println(Double.isNaN(0.0)); // false
System.out.println(Double.isNaN(1.23)); // false
System.out.println(Double.isNaN(-4.56)); // false
System.out.println(Double.isNaN(Double.NaN)); // true
System.out.println(Double.isNaN(Double.NEGATIVE_INFINITY)); // false
System.out.println(Double.isNaN(Double.POSITIVE_INFINITY)); // false
static double longBitsToDouble (long bits)
System.out.println(Double.longBitsToDouble(0x3ff0000000000000L)); // 1.0
System.out.println(Double.longBitsToDouble(0xbff0000000000000L)); // -1.0
System.out.println(Double.longBitsToDouble(0x405ed00000000000L)); // 123.25
System.out.println(Double.longBitsToDouble(0x7ff8000000000000L)); // NaN
System.out.println(Double.longBitsToDouble(0xfff0000000000000L)); // -Infinity
System.out.println(Double.longBitsToDouble(0x7ff0000000000000L)); // Infinity
long longValue ()
final long value1 = Double.valueOf(100.0).longValue();
System.out.println(value1); // 100
final long value2 = Double.valueOf(22.222).longValue();
System.out.println(value2); // 22
final long value3 = Double.valueOf(9.99).longValue();
System.out.println(value3); // 9
System.out.println(Long.MAX_VALUE); // 9223372036854775807
System.out.println(Long.MIN_VALUE); // -9223372036854775808
final long value1 = Double.valueOf(9223372036854775807.0).longValue();
System.out.println(value1); // 9223372036854775807
final long value2 = Double.valueOf(9223372036854775808.0).longValue();
System.out.println(value2); // 9223372036854775807
final long value3 = Double.valueOf(-9223372036854775808.0).longValue();
System.out.println(value3); // -9223372036854775808
final long value4 = Double.valueOf(-9223372036854775809.0).longValue();
System.out.println(value4); // -9223372036854775808
final long value1 = Double.valueOf(Double.NaN).longValue();
System.out.println(value1); // 0
final long value2 = Double.valueOf(Double.NEGATIVE_INFINITY).longValue();
System.out.println(value2); // -9223372036854775808
final long value3 = Double.valueOf(Double.POSITIVE_INFINITY).longValue();
System.out.println(value3); // 9223372036854775807
static double max (double a, double b)
System.out.println(Double.max(1.23, 4.56)); // 4.56
System.out.println(Double.max(-7.89, 7.89)); // 7.89
System.out.println(Double.max(1.23, Double.NaN)); // NaN
System.out.println(Double.max(1.23, Double.NEGATIVE_INFINITY)); // 1.23
System.out.println(Double.max(1.23, Double.POSITIVE_INFINITY)); // Infinity
System.out.println(Double.max(+0.0, -0.0)); // 0.0
static double min (double a, double b)
System.out.println(Double.min(1.23, 4.56)); // 1.23
System.out.println(Double.min(-7.89, 7.89)); // -7.89
System.out.println(Double.min(1.23, Double.NaN)); // NaN
System.out.println(Double.min(1.23, Double.NEGATIVE_INFINITY)); // -Infinity
System.out.println(Double.min(1.23, Double.POSITIVE_INFINITY)); // 1.23
System.out.println(Double.min(+0.0, -0.0)); // -0.0
static double parseDouble (String s)
final double d1 = Double.parseDouble("1.23");
System.out.println(d1); // 1.23
final double d2 = Double.parseDouble("-4.56");
System.out.println(d2); // -4.56
final double d3 = Double.parseDouble("1.234e+3");
System.out.println(d3); // 1234.0
final double d4 = Double.parseDouble("1.234e-3");
System.out.println(d4); // 0.001234
final double d5 = Double.parseDouble("0xffffp-1");
System.out.println(d5); // 32767.5
System.out.println(Double.toHexString(d5)); // 0x1.fffep14
final double d1 = Double.parseDouble("NaN");
System.out.println(d1); // NaN
final double d2 = Double.parseDouble("-Infinity");
System.out.println(d2); // -Infinity
final double d3 = Double.parseDouble("Infinity");
System.out.println(d3); // Infinity
Double resolveConstantDesc (MethodHandles.Lookup lookup)
final var value = Double.valueOf(1.23);
final var ret = value.resolveConstantDesc(MethodHandles.lookup());
System.out.println(ret); // 1.23
short shortValue ()
final short value1 = Double.valueOf(100.0).shortValue();
System.out.println(value1); // 100
final short value2 = Double.valueOf(22.222).shortValue();
System.out.println(value2); // 22
final short value3 = Double.valueOf(9.99).shortValue();
System.out.println(value3); // 9
System.out.println(Short.MAX_VALUE); // 32767
System.out.println(Short.MIN_VALUE); // -32768
final short value1 = Double.valueOf(32767.0).shortValue();
System.out.println(value1); // 32767
final short value2 = Double.valueOf(32768.0).shortValue();
System.out.println(value2); // -32768
final short value3 = Double.valueOf(-32768.0).shortValue();
System.out.println(value3); // -32768
final short value4 = Double.valueOf(-32769.0).shortValue();
System.out.println(value4); // 32767
final short value1 = Double.valueOf(Double.NaN).shortValue();
System.out.println(value1); // 0
final short value2 = Double.valueOf(Double.NEGATIVE_INFINITY).shortValue();
System.out.println(value2); // 0
final short value3 = Double.valueOf(Double.POSITIVE_INFINITY).shortValue();
System.out.println(value3); // -1
static double sum (double a, double b)
System.out.println(Double.sum(1.0, 5.0)); // 6.0
System.out.println(Double.sum(1.0, -5.0)); // -4.0
System.out.println(Double.sum(1.234, Double.NaN)); // NaN
System.out.println(Double.sum(1.234, Double.NEGATIVE_INFINITY)); // -Infinity
System.out.println(Double.sum(1.234, Double.POSITIVE_INFINITY)); // Infinity
// 誤差が発生する例です。
System.out.println(Double.sum(0.1, 0.2)); // 0.30000000000000004
static String toHexString (double d)
System.out.println(Double.toHexString(1.0)); // 0x1.0p0
System.out.println(Double.toHexString(-1.0)); // -0x1.0p0
System.out.println(Double.toHexString(2.0)); // 0x1.0p1
System.out.println(Double.toHexString(3.0)); // 0x1.8p1
System.out.println(Double.toHexString(0.5)); // 0x1.0p-1
System.out.println(Double.toHexString(0.25)); // 0x1.0p-2
System.out.println(Double.toHexString(Double.MAX_VALUE)); // 0x1.fffffffffffffp1023
System.out.println(Double.toHexString(Double.MIN_VALUE)); // 0x0.0000000000001p-1022
System.out.println(Double.toHexString(Double.NaN)); // NaN
System.out.println(Double.toHexString(Double.NEGATIVE_INFINITY)); // -Infinity
System.out.println(Double.toHexString(Double.POSITIVE_INFINITY)); // Infinity
String toString ()
System.out.println(Double.valueOf(1.23).toString()); // 1.23
System.out.println(Double.valueOf(-4.56).toString()); // -4.56
System.out.println(Double.valueOf(1234567890.0).toString()); // 1.23456789E9
System.out.println(Double.valueOf(1.23e-10).toString()); // 1.23E-10
System.out.println(Double.valueOf(0.0).toString()); // 0.0
System.out.println(Double.valueOf(-0.0).toString()); // -0.0
System.out.println(Double.valueOf(Double.MAX_VALUE).toString()); // 1.7976931348623157E308
System.out.println(Double.valueOf(Double.MIN_VALUE).toString()); // 4.9E-324
System.out.println(Double.valueOf(Double.NaN).toString()); // NaN
System.out.println(Double.valueOf(Double.NEGATIVE_INFINITY).toString()); // -Infinity
System.out.println(Double.valueOf(Double.POSITIVE_INFINITY).toString()); // Infinity
static String toString (double d)
System.out.println(Double.toString(1.23)); // 1.23
System.out.println(Double.toString(-4.56)); // -4.56
System.out.println(Double.toString(1234567890.0)); // 1.23456789E9
System.out.println(Double.toString(1.23e-10)); // 1.23E-10
System.out.println(Double.toString(0.0)); // 0.0
System.out.println(Double.toString(-0.0)); // -0.0
System.out.println(Double.toString(Double.MAX_VALUE)); // 1.7976931348623157E308
System.out.println(Double.toString(Double.MIN_VALUE)); // 4.9E-324
System.out.println(Double.toString(Double.NaN)); // NaN
System.out.println(Double.toString(Double.NEGATIVE_INFINITY)); // -Infinity
System.out.println(Double.toString(Double.POSITIVE_INFINITY)); // Infinity
static Double valueOf (double d)
final var d1 = Double.valueOf(1.23);
System.out.println(d1); // 1.23
final var d2 = Double.valueOf(-4.56);
System.out.println(d2); // -4.56
final var d3 = Double.valueOf(1234567890.0);
System.out.println(d3); // 1.23456789E9
final var d4 = Double.valueOf(1.23e-10);
System.out.println(d4); // 1.23E-10
final var d5 = Double.valueOf(Double.MAX_VALUE);
System.out.println(d5); // 1.7976931348623157E308
final var d6 = Double.valueOf(Double.MIN_VALUE);
System.out.println(d6); // 4.9E-324
static Double valueOf (String s)
final var d1 = Double.valueOf("1.23");
System.out.println(d1); // 1.23
final var d2 = Double.valueOf("-4.56");
System.out.println(d2); // -4.56
final var d3 = Double.valueOf("1.234e+3");
System.out.println(d3); // 1234.0
final var d4 = Double.valueOf("1.234e-3");
System.out.println(d4); // 0.001234
final var d5 = Double.valueOf("0xffffp-1");
System.out.println(d5); // 32767.5
System.out.println(Double.toHexString(d5)); // 0x1.fffep14
final var d1 = Double.valueOf("NaN");
System.out.println(d1); // NaN
final var d2 = Double.valueOf("-Infinity");
System.out.println(d2); // -Infinity
final var d3 = Double.valueOf("Infinity");
System.out.println(d3); // Infinity