Main Content

ceilDiv

Round the result of division toward positive infinity

Description

example

y = ceilDiv(x,d) returns the result of x/d rounded to the nearest integer value in the direction of positive infinity.

example

y = ceilDiv(x,d,m) returns the result of x/d rounded to the nearest multiple of m in the direction of positive infinity.

The datatype of y is calculated such that the wordlength and fraction length are of a sufficient size to contain both the largest and smallest possible solutions given the data type of x, and the values of d and m.

Examples

collapse all

Perform a division operation and round to the nearest integer value in the direction of positive infinity.

ceilDiv(int16(201),10)
ans = 

    21

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 14
        FractionLength: 0

Perform a division operation and round to the nearest multiple of 7 in the direction of positive infinity.

ceilDiv(int16(201),10,5)
ans = 

    25

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 14
        FractionLength: 0

Input Arguments

collapse all

Dividend, specified as a scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Divisor, specified as a scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Value to round to nearest multiple of, specified as a scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Output Arguments

collapse all

Result of division and round to ceiling, returned as a scalar.

The datatype of y is calculated such that the wordlength and fraction length are of a sufficient size to contain both the largest and smallest possible solutions given the data type of x, and the values of d and m.

Extended Capabilities

Introduced in R2021a