Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix test on curve #24

Closed
theod opened this issue Feb 5, 2016 · 3 comments
Closed

fix test on curve #24

theod opened this issue Feb 5, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@theod
Copy link
Member

theod commented Feb 5, 2016

there is a strange bug on Curve when trying to test valueAt for the <float, float> curve case :

QVERIFY(curveB->valueAt(-60.) == -60.); //! \note it returns 60. !
QVERIFY(curveB->valueAt(-40.) == -40.); //! \note it returns something like ~39.999... ?!?
QVERIFY(curveB->valueAt(-20.) == -20.); //! \note it returns something like ~19.999... ?!?

all the result are supposed to be made by the same formula in Curve.cpp and CurveSegmentLinear.

maybe you have an idea of what happen here @jcelerier ?

@theod theod added the bug label Feb 5, 2016
@theod theod self-assigned this Feb 5, 2016
@theod theod added this to the release/1.0 milestone Feb 5, 2016
@jcelerier
Copy link
Member

indeed : floating-point numbers are.. well.. floating-point so inexact.
See for instance http://floating-point-gui.de/errors/comparison/

Qt has a function to do the "correct" comparison for floating point values :
http://doc.qt.io/qt-5/qtglobal.html#qFuzzyCompare

@theod
Copy link
Member Author

theod commented Feb 7, 2016

ok thanks for the qFuzzyCompare, this is fixing the <float, float> curve case.
however I've raised another bug which seems much more tricky but certainly relative to double precision.

for a <float, int> curve from (-10., -10) point to (10., 10) point curve->valueAt(-9.) returns -8 !
the test is in CurveTest.cpp and fails as I'm expecting to get -9.

this on feature/2d_curve branch in case you have the time to look at it.

@theod
Copy link
Member Author

theod commented Feb 15, 2016

fixed !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants