question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we need StrictMath and if so what is the cost?

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
MLanghofcommented, Nov 3, 2016

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 represent NaN). Without StrictMath (to my knowledge at least), different implementations/JVMs are all required to return NaN, but their binary representations may differ. I’m not sure if Math allows leeway in the sign of zero, but that would be another thing.

So yes, I think we need StrictMath.

0reactions
MLanghofcommented, Nov 7, 2016

Implemented by #145.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found