Division runtime routine is broken for negative values
Closed this issue · 2 comments
With constant parameters operators are evaluated at compile time, so the underlying Forth division routine is used.
With as yet unsubmitted test that forces one parameter to be non-constant:
div-test:
Assert failed: noconst -1 / -1 Expected: 1 Actual: -1
Assert failed: noconst -1 / 1 Expected: -1 Actual: 1
Assert failed: noconst 8 / -3 Expected: -3 Actual: -2
Assert failed: noconst -8 / -3 Expected: 2 Actual: -2
Assert failed: noconst -8 / 3 Expected: -3 Actual: 2
Assert failed: noconst -32767 / 1 Expected: -32767 Actual: 32767
Assert failed: noconst -32768 / 10 Expected: -3277 Actual: 3276
Assert failed: noconst (-32768) / 10 Expected: -3277 Actual: -3276
8 assert(s) failed.
mod-test:
Assert failed: noconst 8 % -3 Expected: -1 Actual: 2
Assert failed: noconst -8 % 3 Expected: 1 Actual: -2
2 assert(s) failed.
I'm not too happy with how long the division routine currently is, but it seems to do the right thing now.