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>
27 #ifndef _PDCLIB_CONFIG_H
28 #include <_PDCLIB_config.h>
35 TESTCASE( result.quot == 2 && result.rem == 1 );
36 result = div( -5, 2 );
37 TESTCASE( result.quot == -2 && result.rem == -1 );
38 result = div( 5, -2 );
39 TESTCASE( result.quot == -2 && result.rem == 1 );
40 TESTCASE( sizeof( result.quot ) == _PDCLIB_INT_BYTES );
41 TESTCASE( sizeof( result.rem ) == _PDCLIB_INT_BYTES );