-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Cast IntegerNode to float32 in operations like f32 == 1.5
#609
Comments
This is how float comparison works:
|
@antonmedv I think example I gave is more like below. It is true in golang but false in expr
|
In golang |
well in golang literals are automatically casted to proper type right? in below example both float32 and float64 comparison returns true.
|
Yes, type in inherited from left. |
and that is not the case for expr (please refer to my initial example) and that's why I opened issue. I believe Expr internally always cast number to flat64 |
In your example number is float32 |
Is this example more clear? I expect all to be true
result is
|
In first example expr does this
which is false. |
yeah I understand internal - that's why I sent out #610 Don't you think it's confusing though? As shown above
expr expression is false and golang expression is true in this case |
Yes! I think we can work on a proper solution for this. The solution in #610 is not correct. What we need is to cast type to float32 only in case of lhs is float32. This should be done in patcher. |
f32 == 1.5
When you try to compare floating number with floating literal like
Number == 12.34
, it returns false even whenNumber
is 12.34Below is code to reproduce
https://go.dev/play/p/FFgPkXjIURm
The text was updated successfully, but these errors were encountered: