ldiv() — Compute quotient and remainder of integral division

Format

#include <stdlib.h>

ldiv_t ldiv(long int numerator, long int denominator);

General description

The ldiv() function calculates the quotient and remainder of the division of numerator by denominator.

Returned value

The ldiv() function returns a structure of type ldiv_t, containing both the quotient long int quot and the remainder long int rem.

If the value cannot be represented, the returned value is undefined. If denominator is 0, a divide by 0 exception is raised.

Related Information