Main Content

jc_0451: Use of unary minus on unsigned integers

Since R2020a

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

  • NA-MAAB — a

  • JMAAB — a

MATLAB Versions

All

Rule

Sub ID a

Unary minus shall not be used on unsigned integers.

Custom Parameter

Not Applicable

Example — Correct

Example — Incorrect

Negative values cannot be input into 16-bit environments. (Negative values can be input into 32-bit environments.)

Rationale

Sub ID a:

  • As the results are depend on the execution environment, unintended results can occur.

Verification

Model Advisor check: Check usage of unary minus operations in Stateflow charts (Simulink Check)

Last Changed

R2020a

Version History

Introduced in R2020a