Main Content

jc_0481: Use of hard equality comparisons for floating point numbers in Stateflow

Sub ID Recommendations

  • NA-MAAB — a

  • JMAAB — a

MATLAB Versions

All

Rule

Sub ID a

These equality comparison operators shall not be used in floating-point operands:

  • ==

  • !=

  • ~=

Custom Parameter

Not Applicable

Example — Correct

Equality comparison operators are not used in floating-point operands.

Example — Incorrect

Equality comparison operator == is used in floating-point operands.

Rationale

Sub ID a:

  • Due to the nature of the floating-point data type, as it contains an error, the result of the equivalence comparison operation may be false when it was expected to be true.

Verification

Model Advisor check: Check usage of floating-point expressions in Stateflow charts (Simulink Check)

Last Changed

R2020a

See Also

Introduced in R2020a