www.delorie.com/djgpp/doc/libc/libc_533.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

lldiv

Syntax

 
#include <stdlib.h>

lldiv_t lldiv(long long int numerator, long long int denominator);

Description

Returns the quotient and remainder of the division numerator divided by denominator. The return type is as follows:

 
typedef struct {
  long long int quot;
  long long int rem;
} lldiv_t;

Return Value

The results of the division are returned.

Portability

ANSI/ISO C C99; not C89
POSIX 1003.1-2001; not 1003.2-1992

Example

 
lldiv_t l = lldiv(42, 3);
printf("42 = %lld x 3 + %lld\n", l.quot, l.rem);

lldiv(+40, +3) = { +13, +1 }
lldiv(+40, -3) = { -13, +1 }
lldiv(-40, +3) = { -13, -1 }
lldiv(-40, -3) = { +13, -1 }


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004