Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
ldiv.c File Reference
#include <stdlib.h>
Include dependency graph for ldiv.c:

Functions

ldiv_t ldiv (long num, long denom)
 Computes both the quotient and the remainder of the division of the numerator x by the denominator y. More...
 

Function Documentation

◆ ldiv()

ldiv_t ldiv ( long  x,
long  y 
)

Computes both the quotient and the remainder of the division of the numerator x by the denominator y.

Computes both the quotient and the remainder of the division of the numerator x by the denominator y. Computes quotient and remainder simultaneously. The quotient is the algebraic quotient with any fractional part discarded (truncated towards zero). The remainder is such that quot * y + rem == x.

Computes the quotient (the result of the expression x/y) and remainder (the result of the expression xy) simultaneously.

Parameters
xinteger values
yinteger values
Returns
If both the remainder and the quotient can be represented as objects of the corresponding type (int, long, long long, imaxdiv_t, respectively), returns both as an object of type
See also
div_t,
ldiv_t,
lldiv_t,
imaxdiv_t.

If either the remainder or the quotient cannot be represented, the behavior is undefined.

References r.