Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 6-2-2 Usage of std::fpclassify
#1
Hi,

We have seen a creative way to work around MISRA Rule 6-2-2:

Code:
float x = ...;
float y = ...;

if (x == 0.F)  // non-compliant
if (x == y)    // non-compliant

if (std::fpclassify(x)     == FP_ZERO)  // compliant?
if (std::fpclassify(x - y) == FP_ZERO)  // compliant?

Would the last 2 examples be compliant with the rule?

We argue that this is an indirect test for equality and thus non-compliant.
Reply


Messages In This Thread
Rule 6-2-2 Usage of std::fpclassify - by cgpzs - 21-09-2026, 08:37 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)