Hauptinhalt

hisl_0002: Usage of remainder and reciprocal operations

R2026b

To 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 reciprocal function from going to zero.

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.

Simulink models protecting reciprocal Math Function block inputs from zero using comparison with eps and switch logic

B

Protect the input of the rem function from going to zero.

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.

Simulink models protecting rem Math Function block inputs from zero using comparison with eps and switch logic

Tips

  • You can get a divide-by-zero operation, resulting in an infinite (Inf) output value for the reciprocal function, or a Not-a-Number (NaN) output value for the rem function. 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

Version History

Introduced in R2010a

expand all