core: replace IS_FP_SAME macro by inline function

No reason to keep this as a macro - a function is easier to
read, type safe and easier to debug. Moreover, give it the
more appropriate name "nearly_equal()". After all, it precisely
does NOT check floating points for equality.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-08-30 17:55:43 +02:00 committed by Robert C. Helling
parent 5db4a95a26
commit 61701509b0
9 changed files with 28 additions and 25 deletions

View file

@ -442,7 +442,7 @@ double DiveCartesianAxis::posAtValue(double value, double max, double min) const
double screenFrom = position == Position::Bottom ? m.x1() : m.y1();
double screenTo = position == Position::Bottom ? m.x2() : m.y2();
if (IS_FP_SAME(min, max))
if (nearly_equal(min, max))
return (screenFrom + screenTo) / 2.0;
if ((position == Position::Bottom) == inverted)
std::swap(screenFrom, screenTo);

View file

@ -96,7 +96,7 @@ void QMLProfile::setDevicePixelRatio(qreal dpr)
// don't update the profile here, have the user update x and y and then manually trigger an update
void QMLProfile::setXOffset(qreal value)
{
if (IS_FP_SAME(value, m_xOffset))
if (nearly_equal(value, m_xOffset))
return;
m_xOffset = value;
emit xOffsetChanged();
@ -105,7 +105,7 @@ void QMLProfile::setXOffset(qreal value)
// don't update the profile here, have the user update x and y and then manually trigger an update
void QMLProfile::setYOffset(qreal value)
{
if (IS_FP_SAME(value, m_yOffset))
if (nearly_equal(value, m_yOffset))
return;
m_yOffset = value;
emit yOffsetChanged();