5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 div_t div( int numer, int denom )
16 rc.quot = numer / denom;
17 rc.rem = numer % denom;
18 /* TODO: pre-C99 compilers might require modulus corrections */
25 #include <_PDCLIB_test.h>
31 TESTCASE( result.quot == 2 && result.rem == 1 );
32 result = div( -5, 2 );
33 TESTCASE( result.quot == -2 && result.rem == -1 );
34 result = div( 5, -2 );
35 TESTCASE( result.quot == -2 && result.rem == 1 );
36 TESTCASE( sizeof( result.quot ) == sizeof( int ) );
37 TESTCASE( sizeof( result.rem ) == sizeof( int ) );