JDK-8190991 : Forward and Inverse operations accuracy.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9.0.1
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2017-11-09
  • Updated: 2022-03-15
  • Resolved: 2017-11-13
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
Although this relates back to floating point flow errors, it needs to be the case that for float and double values, the digit beyond the final smallest decimal value needs to be rounded up at 0.xxxxxx5 and carried forward if needed, so that operational and inverse functions remain accurate.



JUSTIFICATION :
So that equality tests, == or !=, as well as object tests,
.equals(), will successfully and appropriately detect results
to be where mathematics should be.

To enhance the mathematical accuracy and quality of any java program.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
(pow(sqrt(2),2) == 2) //true

(toDegrees(asin(sin(toRadians(30))))==30) //true.


Comments
For a fixed floating-point format, say double, multiple double values have the same square root. Therefore, it is impossible for pow(sqrt(x), 2) == x for all positive and finite x. Similar situations exist for converting to and from radians. Round-off and imprecision is a fundamental fact of most floating-point computation, unless special circumstances hold. Some of the special circumstances are discussed in "What Every Java Programmer Should Know About Floating-Point Arithmetic," https://www.youtube.com/watch?v=fQ_EtTJHKsM Closing as not a bug.
13-11-2017