Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

div, _div

Integer part of a quotient

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

m div n
_div(x, m)

Description

x div m represents the integer q satisfying x = qm + r with 0 ≤ r < |m|.

For positive x and m, q = x div m is the integer part of the quotient x/m, i.e., q = trunc(x/m).

x div m is equivalent to the function call _div(x, m).

An integer is returned if both x and m evaluate to integers. A symbolic expression of type "_div" is returned if either x or m does not evaluate to a number. An error is raised if x or m evaluates to a number that is not an integer.

div does not operate on polynomials. Use divide.

Examples

Example 1

With the default setting for mod, the identity (x div m) * m + (x mod m) = x holds for integer numbers x and m:

43 div 13 = trunc(43/13), 43 mod 13 = frac(43/13) * 13

(43 div 13) * 13 + (43 mod 13) = 43

Example 2

Symbolic expressions of type "_div" are returned, if either x or m does not evaluate to a number:

43 div m, x div 13, x div m

type(x div m)

If x or m are numbers, they must be integer numbers:

1/2 div 2
Error: The argument is invalid. [div]
x div 2.0
Error: The argument is invalid. [div]

Parameters

x, m

Integers or symbolic arithmetical expressions; m must not be zero.

Return Values

Integer or an arithmetical expression of type "_div".

Overloaded By

m, x

See Also

MuPAD Functions

Was this topic helpful?