Do we need StrictMath and if so what is the cost?
See original GitHub issueI believe out of the box Math
allows for things like SSE optimizations etc. which can create slight differences versus using StrictMath
. I’m not exactly sure what the amount of difference is and the cost of using one over another.
Any ideas?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
In Java is StrictMath still preferred to Math for consistency?
Based on true definition of accuracy, StrictMath is more accurate. Generally speaking Math is faster than StrictMath , but not always the ...
Read more >StrictMath (Java Platform SE 8 ) - Oracle Help Center
The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric ...
Read more >Java.lang.StrictMath class in Java | Set 1 - GeeksforGeeks
StrictMath.abs() method returns the absolute value of any type of the argument passed. This method can handle all the data types.
Read more >Java.lang.StrictMath Class - Tutorialspoint
This method returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal...
Read more >What is the StrictMath.cbrt method in Java? - Educative.io
This method takes a double value for which the cube root is to be found as an argument. If the argument is negative,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I do believe we are one of the cases where bit-for-bit equivalence of results of floating point operations are required.
Worst case, somebody trains a bot with the Genetics that, for whatever reason, depends on a certain operation returning one particular float
NaN
(yes, there are millions of floats that representNaN
). WithoutStrictMath
(to my knowledge at least), different implementations/JVMs are all required to returnNaN
, but their binary representations may differ. I’m not sure ifMath
allows leeway in the sign of zero, but that would be another thing.So yes, I think we need StrictMath.
Implemented by #145.