ldiv
Remonter à Math.h - Index
Header File
math.h
Category
Math Routines
Prototype
ldiv_t ldiv(long int numer, long int denom);
Description
Divides two longs, returning quotient and remainder.
ldiv divides two longs and returns both the quotient and the remainder as an ldiv_t type. numer and denom are the numerator and denominator, respectively.
The ldiv_t type is a structure of longs defined in stdlib.h as follows:
typedef struct {
long int quot; /* quotient */
long int rem; /* remainder */
} ldiv_t;
Return Value
ldiv returns a structure whose elements are quot (the quotient) and rem (the remainder).
Example
/* ldiv example */
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
ldiv_t lx;
lx = ldiv(100000L, 30000L);
printf("100000 div 30000 = %ld remainder %ld\n", lx.quot, lx.rem);
return 0;
}
Portability
POSIX | Win32 | ANSI C | ANSI C++ |
---|---|---|---|
+ |
+ |
+ |
+ |