[apps/continuous_function_cache] abs -> fabs

Replaced abs calls on float with fabs.

Change-Id: I26eda164416ca8b2d601431a59171fd7b00ed33f
This commit is contained in:
Gabriel Ozouf
2020-07-03 16:45:26 +02:00
committed by Émilie Feral
parent 15988f0fae
commit 1de6ac702d

View File

@@ -73,7 +73,7 @@ int ContinuousFunctionCache::indexForParameter(const ContinuousFunction * functi
assert(res >= 0); assert(res >= 0);
if ((res >= k_sizeOfCache && function->plotType() == ContinuousFunction::PlotType::Cartesian) if ((res >= k_sizeOfCache && function->plotType() == ContinuousFunction::PlotType::Cartesian)
|| (res >= k_sizeOfCache / 2 && function->plotType() != ContinuousFunction::PlotType::Cartesian) || (res >= k_sizeOfCache / 2 && function->plotType() != ContinuousFunction::PlotType::Cartesian)
|| std::abs(res - delta) > k_cacheHitTolerance) { || std::fabs(res - delta) > k_cacheHitTolerance) {
return -1; return -1;
} }
assert(function->plotType() == ContinuousFunction::PlotType::Cartesian || m_startOfCache == 0); assert(function->plotType() == ContinuousFunction::PlotType::Cartesian || m_startOfCache == 0);
@@ -103,12 +103,12 @@ void ContinuousFunctionCache::pan(ContinuousFunction * function, float newTMin)
float dT = (newTMin - m_tMin) / m_tStep; float dT = (newTMin - m_tMin) / m_tStep;
m_tMin = newTMin; m_tMin = newTMin;
if (std::abs(dT) > INT_MAX) { if (std::fabs(dT) > INT_MAX) {
clear(); clear();
return; return;
} }
int dI = std::round(dT); int dI = std::round(dT);
if (dI >= k_sizeOfCache || dI <= -k_sizeOfCache || std::abs(dT - dI) > k_cacheHitTolerance) { if (dI >= k_sizeOfCache || dI <= -k_sizeOfCache || std::fabs(dT - dI) > k_cacheHitTolerance) {
clear(); clear();
return; return;
} }