-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Surprising negative results from 32-bit bit ops when compiling to JS #2725
Comments
Marked this as blocking #210. |
This surprising result is per "spec", i.e., dart2js and VM differ how left shift and also modulo/remainder are implemented. cc @floitschG. |
Modulo/remainder should behave correctly. If not, it's a bug. Added Started label. |
Closing as fixed (with r7278). Added Fixed label. |
The surprise for me is not the sign, but that the values differ. hide(x) => [x][0]; prints: 138512695296 Given that the issue is inconsistency between constant folding and evaluation, what was the reasoning behind the decision to change the evaluation (to something less efficient?) |
The compile-time and runtime differences bug is tracked in issue #2887. |
I still get negative results in some cases: main() { The generated code appears to have a bug with operator precedence. $.print(-1 | y >>> 0); Added Triaged label. |
Issue #2908 has been merged into this issue. |
It seems like this needs a bit more work to get the precedence right (comment 7). Set owner to @floitschG. |
Thanks Stephen. |
Committed with r7414. Added Fixed label. |
main() {
var a = [ 0x80 ];
print(a[0] << 24);
print(0x80 << 24);
}
yields:
-2147483648
2147483648
The inconsistency is confusing.
Maybe we could generate JS code that yields positive numbers for 32-bit bitops?
The text was updated successfully, but these errors were encountered: