Previous Page Next Page Contents

div -- the integer part of a quotient

Introduction

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

Call(s)


x div m _div(x, m)

Parameters

x, m - integers or symbolic arithmetical expressions; m must not be zero.

Returns

an integer or an arithmetical expression of type "_div".

Overloadable:

x, m

Related Functions

_mod, /, divide, mod, modp, mods

Details

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
                               3 = 3, 4 = 4
>> (43 div 13) * 13 + (43 mod 13) = 43
                                  43 = 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
                        43 div m, x div 13, x div m
>> type(x div m)
                                  "_div"

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

>> 1/2 div 2
      Error: Illegal argument in div or mod
>> x div 2.0
      Error: Illegal operand [_mod]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000