I'm trying to find how the numerical questions work and an interesting aspect is the way numerical intervals are evaluated.
in numerical/questiontype.php there is this comment
// We need to add a tiny fraction depending on the set precision to make the
// comparison work correctly. Otherwise seemingly equal values can yield
// false. (fixes bug #3225)
I tried looking in the tracker but failed to find it. I would like to know examples of what comparisons (actual number examples) were failing.
Weird!
When i get a mailed copy of my post, the original text has been changed slightly:
// We need to add a tiny fraction depending on the set precision to make the
// comparison work correctly. Otherwise seemingly equal values can yield
// false. (f i x e s b u g # 3 2 2 5)
where (f i x e s b u g # 3 2 2 5) was changed to a link that takes me there.
(I wrote it spaced out now so it won't get changed again by some filter.)
Obviously I am still finding the tracker not fitting my kind of "intuition".
I know I put 3225 into the quick search box and got nothing.
But if I do that now, I get to the issue!
I tried browsing issues, in questions and in quiz sorting by ID but didn't see it.
When I look now I'm wondering, is it only showing "unresolved" issues and that's why it didn't show?
When i get a mailed copy of my post, the original text has been changed slightly:
// We need to add a tiny fraction depending on the set precision to make the
// comparison work correctly. Otherwise seemingly equal values can yield
// false. (f i x e s b u g # 3 2 2 5)
where (f i x e s b u g # 3 2 2 5) was changed to a link that takes me there.
(I wrote it spaced out now so it won't get changed again by some filter.)
Obviously I am still finding the tracker not fitting my kind of "intuition".
I know I put 3225 into the quick search box and got nothing.
But if I do that now, I get to the issue!
I tried browsing issues, in questions and in quiz sorting by ID but didn't see it.
When I look now I'm wondering, is it only showing "unresolved" issues and that's why it didn't show?
The problem is this: Working with limited precision (in base 10) add 1/3 + 1/3 + 1/3. You will end up with something like 0.99999.
Of course, computers work with base 2, but similar things happen. Therefore, when working floats on a computer, you should never test x == y. Instead you should do abs(x - y) < tol for a suitable tol.
When working with floats there is a quantity called epsion, which is the smallest number such that 1 + x > 1 in float arithmetic. Typically in PHP this is about 10^-15. Other things being equal, (in a non-mathematical sense) I have always felt that the square root of this, about 10^-7 or 10^-8 is a good value of tol.
Of course, computers work with base 2, but similar things happen. Therefore, when working floats on a computer, you should never test x == y. Instead you should do abs(x - y) < tol for a suitable tol.
When working with floats there is a quantity called epsion, which is the smallest number such that 1 + x > 1 in float arithmetic. Typically in PHP this is about 10^-15. Other things being equal, (in a non-mathematical sense) I have always felt that the square root of this, about 10^-7 or 10^-8 is a good value of tol.
Hi Jeff,
This has been solved (the tiny interval) by using a value relative to the answer so that small values (i.e. 1e-23 in chemistry) are better handled.
This is to account for the limited precision of real numbers in the digital bit oriented world...
Pierre