-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modulo operator has broken associativity #298
Comments
Thanks for reporting the issue. Thankfully this shouldn't be too hard to fix. |
I've now fixed the issue where units were being ignored. One thing I'm unsure about is the associativity. Currently:
I can't really decide if this should be changed or not. Since most units (kg etc.) don't work inside a modulo expression anyway, I think the current associativity might be fine? |
My two cents: mod having higher precedence than units feels inconsistent with the usage of other operators. Consider:
Without knowing anything else about fend, I would expect this expression to produce an error. Especially considering the behavior of other operators. I guess it would decrease convenience (it's unlikely that the user actually meant With dimensionless units, I would especially expect EDIT: Actually, division works similarly to modulo w.r.t. precedence:
Feels like it should evaluate to |
Just found this: I guess this would be more involved. |
I've now released v1.4.9 which fixes the bug with dropping units, but I'll leave this issue open for the associativity problems. |
It seems that trying to force associativity drops the units within the parentheses. The expression is evaluated as simply
x mod y
. Without parentheses the expression:Evaluates as
(16 mod 6) mebi
As a comparison:
The text was updated successfully, but these errors were encountered: