ID: Title | hisl_0016: Usage of blocks that compute relational operators | ||
---|---|---|---|
Description | To support the robustness of the operations, when using blocks that compute relational operators, including Relational Operator, Compare To Constant, Compare To Zero, Detect Change, and If blocks: | ||
A | Avoid comparisons using the
== or ~= operator on
floating-point data types. | ||
Notes | Due to floating-point
precision issues, do not test floating-point expressions for equality
( When the model contains a block
computing a relational operator with the | ||
Rationale | A | Improve model robustness. | |
Model Advisor Checks | Check for Relational Operator blocks that equate floating-point types (Simulink Check) | ||
References |
| ||
See Also | hisl_0017: Usage of blocks that compute relational operators (2) | ||
Last Changed | R2018a | ||
Examples | Positive Pattern: To test
whether two floating-point variables or expressions are equal, compare
the difference of the two variables against a threshold that takes into
account the floating-point relative accuracy ( The following pattern
shows how to test two double-precision input signals,
|
ID: Title | hisl_0017: Usage of blocks that compute relational operators (2) | ||
---|---|---|---|
Description | To support unambiguous behavior in the generated code, when using blocks that compute relational operators, including Relational Operator, Compare To Constant, Compare to Zero, and Detect Change | ||
A | Set block parameter Output
data type to Boolean . | ||
B | For Relational Operator blocks, verify that input signals are of the same data type. | ||
Rationale | A, B | Support generation of code that produces unambiguous behavior. | |
Model Advisor Checks | Check usage of Relational Operator blocks (Simulink Check) | ||
References |
| ||
See Also | hisl_0016: Usage of blocks that compute relational operators | ||
Last Changed | R2018a |
ID: Title | hisl_0018: Usage of Logical Operator block | ||
---|---|---|---|
Description | To support unambiguous behavior of generated code, when using the Logical Operator block, | ||
A | Set block parameter
Output data type to
| ||
B | Ensure input signals are of type
| ||
Prerequisites | |||
Rationale | A, B | Avoid ambiguous behavior of generated code. | |
Model Advisor Checks | Check usage of Logical Operator blocks (Simulink Check) | ||
References |
| ||
Last Changed | R2017b |
ID: Title | hisl_0019: Usage of bitwise operations | ||
---|---|---|---|
Description | To support unambiguous behavior, when using bitwise operations in Simulink blocks, | ||
A | Avoid signed data types as input to the block. | ||
Notes | Bitwise operations on signed data types are not meaningful. If a shift operation moves a signed bit into a numeric bit, or a numeric bit into a signed bit, unpredictable and unwanted behavior can result. Bitwise blocks include:
| ||
Rationale | A | Support unambiguous behavior of generated code. | |
Model Advisor Checks | Check usage of bit operation blocks (Simulink Check) | ||
References |
| ||
See Also | hisf_0003: Usage of bitwise operations | ||
Last Changed | R2019a |