﻿ Examples of errors detected by the V550 diagnostic

# Examples of errors detected by the V550 diagnostic

V550. An odd precise comparison. It's probably better to use a comparison with defined precision: fabs(A - B) < Epsilon or fabs(A - B) > Epsilon.

## CAMEL

V550 An odd precise comparison: x == 0. It's probably better to use a comparison with defined precision: fabs(A - B) '<' Epsilon. clock_dll sunalgo.cpp 155

``````
void projillum(short* wtab, int xdots, int ydots, double dec)
{
....
s = sin(-dtr(dec));
x = -s * sin(th);
y = cos(th);
....
lon = (y == 0 && x == 0) ? 0.0 : rtd(atan2(y, x));
}
``````

It's strange to expect 'x' and 'y' to exactly equal 0 after all these calculations.

Similar errors can be found in some other places:

• V550 An odd precise comparison: y == 0. It's probably better to use a comparison with defined precision: fabs(A - B) '<' Epsilon. clock_dll sunalgo.cpp 155

## ffdshow

V550 An odd precise comparison: x == 0. It's probably better to use a comparison with defined precision: fabs(A - B) < Epsilon. resample2.cpp 166

``````
static void av_build_filter(....)
{
....
x = M_PI * ((double)(i - center) -
(double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else        y = sin(x) / x;
....
}
``````

It's strange to expect 'x' to exactly equal 0 after all these calculations.

## Windows Calculator

V550 An odd precise comparison: ratio == threshold. It's probably better to use a comparison with defined precision: fabs(A - B) < Epsilon. Calculator AspectRatioTrigger.cpp 80

``````
void AspectRatioTrigger::UpdateIsActive(Size sourceSize)
{
double numerator, denominator;
....
bool isActive = false;
if (denominator > 0)
{
double ratio = numerator / denominator;
double threshold = abs(Threshold);

isActive = ((ratio > threshold) || (ActiveIfEqual && (ratio == threshold)));
}

SetActive(isActive);
}
``````

Similar errors can be found in some other places:

• V550 An odd precise comparison. It's probably better to use a comparison with defined precision: fabs(A - B) < Epsilon. CalcManager UnitConverter.cpp 752
• V550 An odd precise comparison: stod(roundedString) != 0.0. It's probably better to use a comparison with defined precision: fabs(A - B) > Epsilon. CalcManager UnitConverter.cpp 778
• V550 An odd precise comparison. It's probably better to use a comparison with defined precision: fabs(A - B) < Epsilon. CalcManager UnitConverter.cpp 790
• And 9 additional diagnostic messages.

## ArduPod

V550 An odd precise comparison: value != - 1. It's probably better to use a comparison with defined precision: fabs(A - B) > Epsilon. AP_Utils.cpp 574

``````
float AP_Utils::sr04_average(uint8_t trig, uint8_t echo,
int unit, int samples, int time) {
....
float average, pause, value;
....
for(int i=0; i<samples; i++) {
value = sr04(trig, echo, unit);
if(value != -1) { // <=
total += value;
delay(pause);
} else {
i--;
}
}
average = total/samples;
....
return average;
}
``````

427
14 526