Support '%' as modulo operator in calculator
Ashvith10 opened this issue · comments
I did not look into the code, but it seems as if x%y
is interpreted as (x/100)+y
and not as modulo. For modulo one would need x mod y
.
Note that we are using fend for evaluating everything in the calculator.
Yea it seems that fend always treats %
as a unit. They have an open issue to also support it as a module operator, but it seems that it might not be trivial to implement in their parser (printfn/fend#265).
I kinda want to label this as a bug as I agree this is not what the user expects. I don't know exactly how we should fix it though. I think we could either (in order of ascending difficulty and flexibility):
- Hot fix: replace all
([\d]+) *% *([\d]+)
with$1 mod $2
. - It seems that the maintainer of fend wants this as well, so we might be able to fix it in their parser and upstream it.
- Write our own calculator.
Hello, fend maintainer here! I've implemented a fix for this in v1.4.8.
Awesome! Thanks for the heads up