You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DecimalArithmetic panics on division or modulo by zero #123
With gval.DecimalArithmetic(), division or modulo by zero panics with decimal division by 0 instead of returning an error. The panic comes out of Evaluate, so any expression containing / 0 or % 0 crashes an application that evaluates user-supplied expressions in decimal mode.
The /, % and ** operators in gval.go call shopspring/decimal's Div, Mod and Pow directly, and those panic on a zero divisor (Pow divides by the base when the exponent is -1 or less). The default float arithmetic is fine: 1 / 0 gives +Inf.
Reproduced on v1.2.4 and on master (c622ea2). I have a fix and will open a PR.
Activity