Main Content

Use signed shift left for fixed-point operations and multiplication by powers of 2

Replacement of multiplications by powers of two with signed left bitwise shifts

Description

App Configuration Pane: Code Appearance

Configuration Objects: coder.EmbeddedCodeConfig

Replacement of multiplications by powers of two with signed left bitwise shifts in the generated C/C++ code.

GPU Coder™ always sets the EnableSignedLeftShifts property to true.

Some coding standards, such as MISRA™, do not allow bitwise operations on signed integers. To increase the likelihood of generating MISRA C™ compliant code, set EnableSignedLeftShifts to false.

See Control Signed Left Shifts in Generated Code (Embedded Coder).

Settings

On

This value is the default value.

The code generator uses signed left shifts for multiplication by powers of two. An example of generated C code that uses signed left shift for multiplication by eight is:

i <<= 3;

Off

The code generator does not use signed left shifts for multiplication by powers of two. An example of generated C code that does not use signed left shift for multiplication by eight is:

i = i * 8;

Programmatic Use

Property: EnableSignedLeftShifts
Values: true | false
Default: true

Version History

Introduced in R2015a