46 seconds ago

Commons Math is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language or Commons Lang.

Issue 1196: https://issues.apache.org/jira/browse/MATH-1196

FastMath.round (like Math.round) returns incorrect result

Test case:


FastMath.round(x) == 0
FastMath.round(x) == 1

Analyzed Result

32 seconds ago

We instrumented the program to assert that if a number is less than 0.5, the rounding result should be less than 1. ZIYUAN tracked to the statement x + 0:5 in the program and started finding classifiers. In our first attempt, ZIYUAN failed to identify any classifier after a while. Our investigation shows that after the classifier is refined as x  49991269898708784, LIBSVM fails to classify the samples which include the new selective sample simply because the samples are too close. We then implemented a simple classification algorithm (and a simple solver for the same reason) for classifiers in the form of x  c and obtained a predicate x  0:49999999999999991, which reads that when x is smaller than the number, the rounding result is correct.


12 seconds ago

Ziyuan's result in fact generalized the open bug in JDK 6 and 7 (bug number JDK-
6430675) by giving a range of x which could trigger the bug.


We remark this bug remains open however since JDK 8 uses a different implementation, it is not a problem there.


We feed the passed test cases from Ziyuan to Daikon. After a while, Daikon throws an exception as below:

[1:50:32 PM]: Finished reading ./DaikonTestIssue1196.dtrace.gz


LTCore: vals NaN -0.9 -0.9

LTCore: vals NaN -0.85 -0.85

LTCore: vals NaN -0.7999999999999999 -0.7999999999999999

LTCore: vals NaN -0.7499999999999999 -0.7499999999999999

LTCore: vals NaN -0.7499999999999999 -0.7499999999999999

LTCore: vals NaN E-0x.c9e p-t0i.o9n

iinn itnhvr ewaadr n"imnagi:n" t oo few samples for daikon.inv.ternary.threeScalar.LinearTernaryFloat invariant: (x, x, org.apache.commons.majtahv3a..luatnil.gD.eAcsismearlt6i4o.nNEArNr.ovralu

e) daikon.PptSlice 3a:t

odragi.kaopna.cihnev.c.otmemronnasr.mya.tthh3r.eiesSscuaelsa.r.DLaiinkeoanrTTeesrntaIrsysue1196.buCiolrde1F(ldooautb.lese):tu::p(ELiXnIeTa6r2T e rxn axr yoCrogr.eaFplaocahte..jcaovmam:o2n9s1.)math3.u

t aitl .dDaeickiomna.li6n4v..NtAeNr.nvaarlyu.et hsraemepSlcaelsa:r .3L6i


at daikon.DynamicConstants.instantiate_constant_suppressions(DynamicConstants.java:784)

at daikon.DynamicConstants.instantiate_new_views(DynamicConstants.java:489)

at daikon.DynamicConstants.post_process(DynamicConstants.java:937)

at daikon.Daikon.process_data(Daikon.java:1946)

at daikon.Daikon.mainHelper(Daikon.java:573)

at daikon.Daikon.main(Daikon.java:453)


The input of FailureDoc is a sequence. In this case, we manually create below sequence as its input. However, FailureDoc says that the sequence has not error and does not give any explanation.


var0 = prim : double:0x1.fffffffffffffp-2 :

var1 = method : org.apache.commons.math3.util.FastMath.round(double) : var0

var2 = prim : long:0 :

var3 = method : org.junit.Assert.assertEquals(java.lang.Object,java.lang.Object) : var1 var2