1 /* ldiv( long int, long int )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
11 ldiv_t ldiv( long int numer, long int denom )
14 rc.quot = numer / denom;
15 rc.rem = numer % denom;
16 /* TODO: pre-C99 compilers might require modulus corrections */
23 #include <_PDCLIB_test.h>
28 result = ldiv( 5, 2 );
29 TESTCASE( result.quot == 2 && result.rem == 1 );
30 result = ldiv( -5, 2 );
31 TESTCASE( result.quot == -2 && result.rem == -1 );
32 result = ldiv( 5, -2 );
33 TESTCASE( result.quot == -2 && result.rem == 1 );
34 TESTCASE( sizeof( result.quot ) == sizeof( long ) );
35 TESTCASE( sizeof( result.rem ) == sizeof( long ) );