]> git.sur5r.net Git - cc65/blob - test/ref/divmod.c
remote TABs in doc/ and test/
[cc65] / test / ref / divmod.c
1 /*
2   !!DESCRIPTION!! div/mod test
3   !!ORIGIN!!
4   !!LICENCE!!     public domain
5 */
6
7 #include <stdio.h>
8
9 void printc(signed char a,signed char b){
10 signed char x=a/b,y=a%b,z=a*b;
11         printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
12 }
13 void prints(short a,short b){
14 short x=a/b,y=a%b,z=a*b;
15         printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
16 }
17 void printl(long a,long b){
18 long x=a/b,y=a%b,z=a*b;
19         printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);
20 }
21
22 int main(void) {
23         printl( 3,-2);
24         printl(-3,-2);
25         printl(-3, 2);
26         printl( 3, 2);
27         printf("-\n");
28         prints( 3,-2);
29         prints(-3,-2);
30         prints(-3, 2);
31         prints( 3, 2);
32         printf("-\n");
33         printc( 3,-2);
34         printc(-3,-2);
35         printc(-3, 2);
36         printc( 3, 2);
37         return 0;
38 }