hisl_0002: Usage of remainder and reciprocal operations
R2026bTo support robustness of generated code, when using the Math Function block with
remainder-after-division (rem) or reciprocal
(reciprocal) operations
Usage: High-Integrity System Modeling
Guideline ID: hisl_0002
Rules
| hisl_0002: Usage of remainder and reciprocal operations | |
|---|---|
| A | Protect the input of the
Rationale Protect against overflows and undefined numerical results. Verification Check usage of remainder and reciprocal operations (Simulink Check) Example In the following example, when the input signal to the reciprocal function oscillates around zero, the output exhibits a large change in value. You need further protection against the large change in value.
|
| B | Protect the input of the
Rationale Protect against overflows and undefined numerical results. Verification Check usage of remainder and reciprocal operations (Simulink Check) Example In the following example, when the second input signal to the rem function oscillates around zero, the output produces undefined values. You need further protection against the second input going to zero.
|
Tips
You can get a divide-by-zero operation, resulting in an infinite (
Inf) output value for thereciprocalfunction, or a Not-a-Number (NaN) output value for theremfunction. To avoid overflows or undefined values, protect the corresponding input from going to zero.
Industry Standards
IEC 61508-3, Table A.3 (3) 'Language subset'
IEC 61508-3, Table A.4 (3) 'Defensive programming'IEC 62304, 5.5.3 - Software Unit acceptance criteria
ISO 26262-6, Table 1(b) 'Use of language subsets'
ISO 26262-6, Table 1(d) 'Use of defensive implementation techniques'EN 50128, Table A.4 (11) 'Language Subset'
EN 50128, Table A.3 (1) 'Defensive Programming'EN 50657, Table A.4 (11) 'Language Subset'
EN 50657, Table A.3 (1) 'Defensive Programming'EN 50716, Table A.3 (1) 'Defensive Programming'
DO-331, Section MB.6.3.2.g 'Algorithms are accurate'
MISRA C:2012, Dir 4.1
MISRA C:2023, Dir 4.1
INT33-C. Ensure that division and remainder operations do not result in divide-by-zero errors

