Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

ldiv - long division of integers

&pagelevel(4)&pagelevel

Syntax

#include <stdlib.h>

ldiv_t ldiv(long int dividend, long int divisor);

Description

ldiv() computes the quotient and remainder of the division of dividend by divisor.

Both the arguments and the result are of type long int.

The sign of the quotient is the same as the sign of the algebraic quotient. The value of the equotient is the highest integer less than or equal to the absolute value of the algebraic quotient.

The remainder is expressed by the following equation:

Quotient * Divisor + Remainder = Dividend

Return val.

Structure of type ldiv_t

if successful. The structure includes the quotient quot as well as the remainder rem as long values.

See also

div(), lldiv()stdlib.h.