Main Content

Signed integer division rounds to

How test hardware compiler rounds signed integer division results

Model Configuration Pane: Hardware Implementation

Description

Specify 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

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

NDIdeal N/DResult for Zero RoundingResult for Floor RoundingResult for 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

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.

Tips

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

  • 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 parameters affect the rounding behavior. For more information, see Rounding (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