1 /* lldiv( long long int, long 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 lldiv_t lldiv( long long int numer, long 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 = lldiv( 5ll, 2ll );
29 TESTCASE( result.quot == 2 && result.rem == 1 );
30 result = lldiv( -5ll, 2ll );
31 TESTCASE( result.quot == -2 && result.rem == -1 );
32 result = lldiv( 5ll, -2ll );
33 TESTCASE( result.quot == -2 && result.rem == 1 );
34 TESTCASE( sizeof( result.quot ) == sizeof( long long ) );
35 TESTCASE( sizeof( result.rem ) == sizeof( long long ) );