Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/waterbox/libc/functions/stdlib/lldiv.c
2 views
1
/* lldiv( long long int, long long int )
2
3
This file is part of the Public Domain C Library (PDCLib).
4
Permission is granted to use, modify, and / or redistribute at will.
5
*/
6
7
#include <stdlib.h>
8
9
#ifndef REGTEST
10
11
lldiv_t lldiv( long long int numer, long long int denom )
12
{
13
lldiv_t rc;
14
rc.quot = numer / denom;
15
rc.rem = numer % denom;
16
/* TODO: pre-C99 compilers might require modulus corrections */
17
return rc;
18
}
19
20
#endif
21
22
#ifdef TEST
23
#include "_PDCLIB_test.h"
24
25
int main( void )
26
{
27
lldiv_t result;
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 ) );
36
return TEST_RESULTS;
37
}
38
39
#endif
40
41