aboutsummaryrefslogtreecommitdiff
path: root/tinycc/tests/tests2/61_integers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tinycc/tests/tests2/61_integers.c')
-rw-r--r--tinycc/tests/tests2/61_integers.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/tinycc/tests/tests2/61_integers.c b/tinycc/tests/tests2/61_integers.c
new file mode 100644
index 0000000..de29b3c
--- /dev/null
+++ b/tinycc/tests/tests2/61_integers.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+
+/* This was first introduced to test the ARM port */
+
+#define UINT_MAX ((unsigned) -1)
+
+int main()
+{
+ printf("18/21=%u\n", 18/21);
+ printf("18%%21=%u\n", 18%21);
+ printf("41/21=%u\n", 41/21);
+ printf("41%%21=%u\n", 41%21);
+ printf("42/21=%u\n", 42/21);
+ printf("42%%21=%u\n", 42%21);
+ printf("43/21=%u\n", 43/21);
+ printf("43%%21=%u\n", 43%21);
+ printf("126/21=%u\n", 126/21);
+ printf("126%%21=%u\n", 126%21);
+ printf("131/21=%u\n", 131/21);
+ printf("131%%21=%u\n", 131%21);
+ printf("(UINT_MAX/2+3)/2=%u\n", (UINT_MAX/2+3)/2);
+ printf("(UINT_MAX/2+3)%%2=%u\n", (UINT_MAX/2+3)%2);
+
+ printf("18/-21=%u\n", 18/-21);
+ printf("18%%-21=%u\n", 18%-21);
+ printf("41/-21=%u\n", 41/-21);
+ printf("41%%-21=%u\n", 41%-21);
+ printf("42/-21=%u\n", 42/-21);
+ printf("42%%-21=%u\n", 42%-21);
+ printf("43/-21=%u\n", 43/-21);
+ printf("43%%-21=%u\n", 43%-21);
+ printf("126/-21=%u\n", 126/-21);
+ printf("126%%-21=%u\n", 126%-21);
+ printf("131/-21=%u\n", 131/-21);
+ printf("131%%-21=%u\n", 131%-21);
+ printf("(UINT_MAX/2+3)/-2=%u\n", (UINT_MAX/2+3)/-2);
+ printf("(UINT_MAX/2+3)%%-2=%u\n", (UINT_MAX/2+3)%-2);
+
+ printf("-18/21=%u\n", -18/21);
+ printf("-18%%21=%u\n", -18%21);
+ printf("-41/21=%u\n", -41/21);
+ printf("-41%%21=%u\n", -41%21);
+ printf("-42/21=%u\n", -42/21);
+ printf("-42%%21=%u\n", -42%21);
+ printf("-43/21=%u\n", -43/21);
+ printf("-43%%21=%u\n", -43%21);
+ printf("-126/21=%u\n", -126/21);
+ printf("-126%%21=%u\n", -126%21);
+ printf("-131/21=%u\n", -131/21);
+ printf("-131%%21=%u\n", -131%21);
+ printf("-(UINT_MAX/2+3)/2=%u\n", (0-(UINT_MAX/2+3))/2);
+ printf("-(UINT_MAX/2+3)%%2=%u\n", (0-(UINT_MAX/2+3))%2);
+
+ printf("-18/-21=%u\n", -18/-21);
+ printf("-18%%-21=%u\n", -18%-21);
+ printf("-41/-21=%u\n", -41/-21);
+ printf("-41%%-21=%u\n", -41%-21);
+ printf("-42/-21=%u\n", -42/-21);
+ printf("-42%%-21=%u\n", -42%-21);
+ printf("-43/-21=%u\n", -43/-21);
+ printf("-43%%-21=%u\n", -43%-21);
+ printf("-126/-21=%u\n", -126/-21);
+ printf("-126%%-21=%u\n", -126%-21);
+ printf("-131/-21=%u\n", -131/-21);
+ printf("-131%%-21=%u\n", -131%-21);
+ printf("-(UINT_MAX/2+3)/-2=%u\n", (0-(UINT_MAX/2+3))/-2);
+ printf("-(UINT_MAX/2+3)%%-2=%u\n", (0-(UINT_MAX/2+3))%-2);
+
+ return 0;
+}