revert between 56095 -> 55830 in arch
[AROS.git] / compiler / stdc / ldiv.c
blob9dad466a256be29471e1264199a027e135792b3d
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: C99 function ldiv
6 */
8 /*****************************************************************************
10 NAME */
11 #include <stdlib.h>
13 ldiv_t ldiv (
15 /* SYNOPSIS */
16 long int numer,
17 long int denom)
19 /* FUNCTION
20 Compute quotient en remainder of two long variables
22 INPUTS
23 numer = the numerator
24 denom = the denominator
26 RESULT
27 a struct with two long ints quot and rem with
28 quot = numer / denom and rem = numer % denom.
30 typedef struct ldiv_t {
31 long int quot;
32 long int rem;
33 } ldiv_t;
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 div()
44 INTERNALS
46 ******************************************************************************/
48 ldiv_t ret;
50 ret.quot = numer / denom;
51 ret.rem = numer % denom;
53 /* See div() for why we do this */
54 if (numer >= 0 && ret.rem < 0)
56 ret.quot++;
57 ret.rem -= denom;
59 return ret;