JDK-8285477 : Add a PRECISION public static field to j.l.Float and j.l.Double
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • Submitted: 2022-04-22
  • Updated: 2022-07-29
  • Resolved: 2022-04-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b20Fixed
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Add a PRECISION public static final field to java.lang.Float and java.lang.Double

Problem
-------

The precision of float and double values, as defined by IEEE 754, is not easily derivable from the constants in the java.lang.Float resp. java.lang.Double classes. These values (24 resp. 53) are used in some places in the OpenJDK code base, where they appear as literals or even as derived literals, like 23 and 52. Hence, usages of these values are harder to find than necessary.

Solution
--------

It is proposed to add a PRECISION public static field to these classes. The values for MAX_EXPONENT and MIN_EXPONENT are then derived from static expressions at compile time, rather than being defined as literals.

Later enhancements could then replace the literals in the code base with the field names.
Comments
Changeset: fb605944 Author: Raffaello Giulietti <raffaello.giulietti@oracle.com> Committer: Joe Darcy <darcy@openjdk.org> Date: 2022-04-25 17:18:46 +0000 URL: https://git.openjdk.java.net/jdk/commit/fb605944b5b734c8b47a9122e7ab3d3dcf55f71e
25-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8362 Date: 2022-04-22 14:26:07 +0000
22-04-2022