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
Hey there, I was playing with this awesome expression library awhile! But I hit a bug that ended-up do me to debugging my app for a few hours. And noticed it was due to my expression which blocking my progress on my project currently. I also search for whether this is a known issue or not, but couldn't find much. Here is a minimal reproducible snippet:
Given foo is 3 and bar is 5, resulting 0 if we evaluate with (foo / bar) expression. But actually it should return 0.6 instead. So eventually my (foo / bar) < 0.5 expression also return false instead of true. It's evaluating as true because of 0 < 0.5 is "true".
I'm not so sure if it's correct by design, since int/int resulting int in Go. So that expr resulting 0 as expected. But from the end-user perspective, I was expecting it should have floating-point value. (at least this is what most modern calculators' do, given 3/5 is just 0.6.)
Tested with the following primitive types: byte, int8, int16, int32, int64, uint8, uint16, uint32, uint64
Works only if all the given parameters are: float32 and float64
The text was updated successfully, but these errors were encountered:
This is nice point. I think we can change resulting type for / op to float64.
Cool! What about other operators? I think all operators should result float64. 🤔 (i.e. 1.5 + 9.3333, 9 - 8.9, 0.0003 * 2.33, didn't test, just for an example.)
Dentrax
added a commit
to Dentrax/expr
that referenced
this issue
Nov 4, 2022
Hey there, I was playing with this awesome expression library awhile! But I hit a bug that ended-up do me to debugging my app for a few hours. And noticed it was due to my expression which blocking my progress on my project currently. I also search for whether this is a known issue or not, but couldn't find much. Here is a minimal reproducible snippet:
Bug
Given
foo
is3
andbar
is5
, resulting0
if we evaluate with(foo / bar)
expression. But actually it should return0.6
instead. So eventually my(foo / bar) < 0.5
expression also returnfalse
instead oftrue
. It's evaluating as true because of0 < 0.5
is "true".I'm not so sure if it's correct by design, since
int/int
resultingint
in Go. So thatexpr
resulting0
as expected. But from the end-user perspective, I was expecting it should have floating-point value. (at least this is what most modern calculators' do, given 3/5 is just 0.6.)byte
,int8
,int16
,int32
,int64
,uint8
,uint16
,uint32
,uint64
float32
andfloat64
The text was updated successfully, but these errors were encountered: