impl modulo (handle negative divisors how people expect)
This commit is contained in:
parent
2b6aff0dab
commit
ce991fd12a
2 changed files with 7 additions and 0 deletions
src/lib
|
@ -11,6 +11,11 @@ describe("expr", () => {
|
|||
["1 * 2", "2"],
|
||||
["1 / 2", "0.5"],
|
||||
["1 // 2", "0"],
|
||||
["1 % 2", "1"],
|
||||
["3 % 2", "1"],
|
||||
["-1 % 2", "1"],
|
||||
// TODO: might change this! negative dividend is weird no matter what, but positive modulo is arguably the better call?
|
||||
["1 % -2", "-1"],
|
||||
// TODO: operator precedence
|
||||
// TODO: parentheses
|
||||
])("%s", (expression, result) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue