8285477: Add a PRECISION public static field to j.l.Float and j.l.Double
Reviewed-by: darcy
This commit is contained in:
parent
1e79ded98a
commit
fb605944b5
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -205,6 +205,22 @@ public final class Double extends Number
|
||||
*/
|
||||
public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
|
||||
|
||||
/**
|
||||
* The number of bits used to represent a {@code double} value.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final int SIZE = 64;
|
||||
|
||||
/**
|
||||
* The number of bits in the significand of a {@code double} value.
|
||||
* This is the parameter N in section {@jls 4.2.3} of
|
||||
* <cite>The Java Language Specification</cite>.
|
||||
*
|
||||
* @since 19
|
||||
*/
|
||||
public static final int PRECISION = 53;
|
||||
|
||||
/**
|
||||
* Maximum exponent a finite {@code double} variable may have.
|
||||
* It is equal to the value returned by
|
||||
@ -212,7 +228,7 @@ public final class Double extends Number
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final int MAX_EXPONENT = 1023;
|
||||
public static final int MAX_EXPONENT = (1 << (SIZE - PRECISION - 1)) - 1; // 1023
|
||||
|
||||
/**
|
||||
* Minimum exponent a normalized {@code double} variable may
|
||||
@ -221,14 +237,7 @@ public final class Double extends Number
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final int MIN_EXPONENT = -1022;
|
||||
|
||||
/**
|
||||
* The number of bits used to represent a {@code double} value.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final int SIZE = 64;
|
||||
public static final int MIN_EXPONENT = 1 - MAX_EXPONENT; // -1022
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code double} value.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -115,6 +115,22 @@ public final class Float extends Number
|
||||
*/
|
||||
public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
|
||||
|
||||
/**
|
||||
* The number of bits used to represent a {@code float} value.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final int SIZE = 32;
|
||||
|
||||
/**
|
||||
* The number of bits in the significand of a {@code float} value.
|
||||
* This is the parameter N in section {@jls 4.2.3} of
|
||||
* <cite>The Java Language Specification</cite>.
|
||||
*
|
||||
* @since 19
|
||||
*/
|
||||
public static final int PRECISION = 24;
|
||||
|
||||
/**
|
||||
* Maximum exponent a finite {@code float} variable may have. It
|
||||
* is equal to the value returned by {@code
|
||||
@ -122,7 +138,7 @@ public final class Float extends Number
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final int MAX_EXPONENT = 127;
|
||||
public static final int MAX_EXPONENT = (1 << (SIZE - PRECISION - 1)) - 1; // 127
|
||||
|
||||
/**
|
||||
* Minimum exponent a normalized {@code float} variable may have.
|
||||
@ -131,14 +147,7 @@ public final class Float extends Number
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public static final int MIN_EXPONENT = -126;
|
||||
|
||||
/**
|
||||
* The number of bits used to represent a {@code float} value.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final int SIZE = 32;
|
||||
public static final int MIN_EXPONENT = 1 - MAX_EXPONENT; // -126
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code float} value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user