java - Math.pow yields different results upon repeated calls -


Errors were reported in our testing system after upgrading to Java 1.8.0_20, but the code did not change.

I came to know that, Math.pow () is called with the same input parameter, generates different results on the call that is sent again. In Java 1.8.0_11, it behaves as expected and always gives the same value, but sometimes with Java 1.8.0_20 and sometimes even slightly different values.

This is similar to the question, but it is different because the results are different (Pau) within a VM. The following Jute Testing fails when running under Java 1.8.0_20 and higher

 . Import static org.junit.assert.assertEquals; Import java.util.function.BiFunction; Import org.junit.BeforeClass; Import org.junit.Test; Public Class PowersTest {Private Static Final NN = 1000000; Private stable final double base = 5350.45632 9377186; Personal stable last double app = 2.0; Private Stable Double Eval (Last Biology & Lt; Double, Double, Double & gt; F) {Return F. Apli (base, APP); } Private Zero Loop (Last Byfunction & lt; Double, Double, Double & gt; F) {Final Double X = eval (f); (Ultimate Double P = eval (f); AssertEquals ("i =" + i, x, p, 0);}} @ Bayverclass Public Stabilizer for (Int i = 0; I & lt; N; i ++) Zero Information () {System.out.println ("Java" + System.getProperty ("java.version"))} @Test Public Zero Mathematics () {Loop (Math :: Pau);} @Test Public Zero Hard Mathpau () {Loop (Stick Math :: Pau);}}  

Test is not unsuccessful under Java 1.8.0_11 or if the hotspot is with -Xint Pau's harsh mathematical version () produces consistent results. Pot GIT suspects some optimization that switches on a different implementation of Pow (), which yields different results for some input value. A mathematical function must be deterministic and it will be continuously and reproduced.

Is this a bug or a feature?

I have received the following bug report:

It is very similar to this one Reports Loting-point operation which Jeaiteed code vs. interpreted code.

The problem has been marked as a bug and it has been fixed. On this basis, I will argue that what you are seeing is also a bug and it should be reported in Oracle.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -