#include <stdlib.h>
|
|
lldiv_t
lldiv (long long numer, long long denom); Sh RETURN VALUES The lldiv function returns a structure of type lldiv_t that contains two long long members named quot (quotient) and rem (remainder). |
The lldiv_t type is defined as:
typedef struct {
long long quot; /* Quotient. */
long long rem; /* Remainder. */
} lldiv_t;
#include <stdlib.h>
#include <stdio.h>
#include <math.h> /* link to the math lib -libm */
int main( void )
{
long long numer = pow(2, 40);
long long denom = 3;
/* call to lldiv */
lldiv_t x = lldiv(-numer, denom);
printf("Result-> \nQuotient = %ld \nRemainder = %ld", x.quot, x.rem);
long long exp_numer = (denom * x.quot) + x.rem;
if( exp_numer == (-numer) )
printf("\nExpected output");
else
printf("Unexpected output");
return 0;
}
Output
Result->
Quotient = -366503875925
Remainder = -1
Expected output
|
© 2005-2007 Nokia |