Divide input by a constant and round to integer (2024)

Main Content

Divide input by a constant and round to integer

Since R2021a

expand all in page

  • Divide input by a constant and round to integer (1)

Divide input by a constant and round to integer (2)

Libraries:
Fixed-Point Designer

Description

The Divide by Constant and Round block outputs the result of dividing the input by a constant and rounds the result to an integer using the specified rounding method.

The Divide by Constant and Round block uses an algorithm that is functionally similar to the Granlund-Montgomery-Warren Method. The division operation is computed via a multiplication by inverse, which generally results in better performance on embedded systems.

Ports

Input

expand all

Dividend, specified as a scalar, vector, matrix, or N-D array.

Divide by Constant and Round does not support data types with word length greater than 128. Slope-bias representation is not supported for fixed-point data types.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point
Complex Number Support: Yes

Output

expand all

Result of division and round operation, returned as a scalar, vector, matrix, or N-D array.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point

Parameters

expand all

Divisor, specified as a positive, real-valued, finite scalar.

Programmatic Use

Block Parameter: Denominator
Type: character vector
Values: MATLAB® expression that evaluates to a positive, real-valued, finite fixed point or numeric value
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Default: '10'

Rounding method to use, specified as one of these values:

  • Floor — Round to nearest integer in the direction of negative infinity.

  • Ceiling — Round to nearest integer in the direction of positive infinity.

  • Nearest — Round to the nearest integer. Ties are rounded to the nearest integer in the direction of positive infinity.

  • Zero — Round to the nearest integer in the direction of zero.

  • Convergent — Round to the nearest integer. Ties are rounded to the nearest even integer.

Programmatic Use

Block Parameter: RndMeth
Type: character vector
Values: 'Floor' | 'Ceiling' | 'Nearest' | 'Zero' | 'Convergent'
Default: 'Floor'

Extended Capabilities

Slope-bias representation is not supported for fixed-point data types.

Version History

Introduced in R2021a

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Divide input by a constant and round to integer (3)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

Europe

Asia Pacific

Contact your local office

Divide input by a constant and round to integer (2024)
Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 5749

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.