Main Content

Signed integer division rounds to

How test hardware compiler rounds signed integer division results

Model Configuration Pane: Hardware Implementation

Description

The Signed integer division rounds to parameter specifies how the compiler for the test hardware rounds the result of dividing two signed integers.

For information on how this option affects code generation, see Hardware Implementation Options (Simulink Coder).

Selecting a device by using the Device vendor and Device type parameters sets a device-specific value for this parameter.

Dependencies

This parameter is enabled only if you can modify it for the selected hardware.

Settings

Zero (default) | Floor | Undefined
Zero

If the quotient is between two integers, the compiler chooses the integer that is closer to zero as the result.

Floor

If the quotient is between two integers, the compiler chooses the integer that is closer to negative infinity.

Undefined

Choose this option if neither Zero nor Floor describes the compiler behavior, or if that behavior is unknown.

The table summarizes the compiler behavior that corresponds to each parameter option.

NumeratorDenominatorExact QuotientResult with Zero RoundingResult with Floor RoundingResult with Undefined Rounding

33

4

8.25

8

8

8

-33

4

-8.25

-8

-9

-8 or -9

33

-4

-8.25

-8

-9

-8 or -9

-33

-4

8.25

8

8

8 or 9

Tips

  • By setting the Integer rounding mode parameter for blocks in the model, you can simulate the rounding behavior of the C compiler that you use to compile code generated from your model. The parameter is on the Signal Attributes tab of the Block Parameters dialog box for blocks that support signed integer arithmetic, for example, the Product block.

  • For most blocks, the Integer rounding mode parameter value for the block completely specifies the rounding behavior. For blocks that support fixed-point data types and the Simplest rounding mode, both the Integer rounding mode parameter and the Signed integer division rounds to parameter affect the rounding behavior. For more information, see Rounding Modes (Fixed-Point Designer).

Recommended Settings

ApplicationSetting
DebuggingNo impact for simulation or during development.
Undefined for production code generation.
TraceabilityNo impact for simulation or during development.
Zero or Floor for production code generation.
EfficiencyNo impact for simulation or during development.
Zero for production code generation.
Safety precaution

No impact when Test hardware is the same as production hardware is selected. If it is not selected, no recommendation.

Programmatic Use

Parameter: TargetIntDivRoundTo
Type: string | character vector
Values: 'Floor' | 'Zero' | 'Undefined'
Default: 'Zero'

Version History

Introduced in R2006a