Fixed incorrect division results

This commit is contained in:
2025-02-22 12:54:23 +01:00
parent 7598411c8f
commit c088697446
11 changed files with 150 additions and 94 deletions

View File

@ -1,13 +1,11 @@
main() {
quotient := 0
remainder := 0
dividend := 256
divisor := 100
quotient, remainder = 256 / 100
quotient, remainder := 256 / 100
assert quotient == 2
assert remainder == 56
quotient, remainder = dividend / 100
assert quotient == 2
assert remainder == 56
@ -15,7 +13,7 @@ main() {
quotient, remainder = 256 / divisor
assert quotient == 2
assert remainder == 56
quotient, remainder = dividend / divisor
assert quotient == 2
assert remainder == 56

View File

@ -1,9 +0,0 @@
main() {
f(10)
}
f(new int) {
old := new
new -= 1
assert new != old
}

View File

@ -0,0 +1,30 @@
main() {
number(10)
register(10)
}
number(x int) {
y := x
x -= 1
assert x < y
x += 1
assert x == y
x *= 2
assert x > y
x /= 2
assert x == y
}
register(x int) {
y := x
num := 1
x -= num
assert x < y
x += num
assert x == y
num = 2
x *= num
assert x > y
x /= num
assert x == y
}

View File

@ -7,11 +7,11 @@ main() {
f := 6
g := 7
assert a != 0
assert b != 0
assert c != 0
assert d != 0
assert e != 0
assert f != 0
assert g != 0
assert a == 1
assert b == 2
assert c == 3
assert d == 4
assert e == 5
assert f == 6
assert g == 7
}