diff options
Diffstat (limited to 'prelude.c')
-rw-r--r-- | prelude.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/prelude.c b/prelude.c new file mode 100644 index 0000000..bb345c4 --- /dev/null +++ b/prelude.c @@ -0,0 +1,13 @@ +int builtin_divInt(int x, int y) { + return + (x > 0 && y < 0) ? (x - 1) / y - 1 + : (x < 0 && y > 0) ? (x + 1) / y - 1 + : x / y; +} + +int builtin_modInt(int x, int y) { + return + (x > 0 && y < 0) ? (x - 1) % y + y + 1 + : (x < 0 && y > 0) ? (x + 1) % y + y - 1 + : x % y; +} |