summaryrefslogtreecommitdiff
path: root/prelude.c
blob: bb345c4352c2b5e1c4253d230fe24d1dcb36dd33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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;
}