Fix: 64-bit compatibility
[AROS.git] / compiler / stdc / lldiv.c
blob9ec693a2e712c6c4ff7e79f51144cbc488614bca
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: C99 function lldiv
6 */
8 #include <aros/system.h>
9 #if defined(AROS_HAVE_LONG_LONG)
11 /*****************************************************************************
13 NAME */
14 #include <stdlib.h>
16 lldiv_t lldiv (
18 /* SYNOPSIS */
19 long long int numer,
20 long long int denom)
22 /* FUNCTION
23 Compute quotient en remainder of two long long variables
25 INPUTS
26 numer = the numerator
27 denom = the denominator
29 RESULT
30 a struct with two long ints quot and rem with
31 quot = numer / denom and rem = numer % denom.
33 typedef struct lldiv_t {
34 long long int quot;
35 long long int rem;
36 } lldiv_t;
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 div(), ldiv()
47 INTERNALS
49 ******************************************************************************/
51 lldiv_t ret;
53 ret.quot = numer / denom;
54 ret.rem = numer % denom;
56 /* See div.c for why this is done */
57 if (numer >= 0 && ret.rem < 0)
59 ret.quot++;
60 ret.rem -= denom;
63 return ret;
65 #endif /* AROS_HAVE_LONG_LONG */