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
In a flutter application, when the device selected to run (in VS Code) is Chrome or Edge browser (web-javascript), the MadeHand.best() method return is not always right. Probably due to integer is 32 bit in JavaScript in browser and 64 bit in Dart/Flutter?
When device is browser, MadeHand.best() hand evaluation result is not consistent at all. For example,
cards 'QdKsQsJhTd9h8c' or 'KsQsJhTd9h' evaluated to be MadeHandType.fullHouse with a hashcode of 167
cards '6d2s4s5h3d' evaluated to be MadeHandType.fullHouse with a hashcode of 265
cards '6d2s4s5h3d2hQd' evaluated to be MadeHandType.trips with a hashcode of 2270
cards 'Ad2s4s5h3d2h2d' evaluated to be right as MadeHandType.straight with a hashcode of 1609, yet the 5 cards straight 'Ad2s4s5h3d' evaluated to be MadeHandType.fullHouse with a hashcode of 265
However, if device selected is a Android emulator (Pixel 6 API 29), all the above cards are correctly evaluated to be MadeHandType.straight.
A little more digging and I think the issue is in ImmutableCardSet class, where the _indexUnion probably should be fixnum:Int64 to be JS safe. Though JS number can be as large as 2^53-1, however, any bit operations in JS are operated on 32 bit int. So any bit operation on integer larger than 2^32-1 inside JS would cause issue.
The text was updated successfully, but these errors were encountered:
wfzhou2
changed the title
JS support issue of MadeHand.best() when flutter code compiled to JS to run on Chrome or Edge browser
JS support issue of MadeHand.best(): when flutter code compiled to JS to run on Chrome or Edge browser
Nov 18, 2022
In a flutter application, when the device selected to run (in VS Code) is Chrome or Edge browser (web-javascript), the MadeHand.best() method return is not always right. Probably due to integer is 32 bit in JavaScript in browser and 64 bit in Dart/Flutter?
When device is browser, MadeHand.best() hand evaluation result is not consistent at all. For example,
However, if device selected is a Android emulator (Pixel 6 API 29), all the above cards are correctly evaluated to be MadeHandType.straight.
A little more digging and I think the issue is in ImmutableCardSet class, where the _indexUnion probably should be fixnum:Int64 to be JS safe. Though JS number can be as large as 2^53-1, however, any bit operations in JS are operated on 32 bit int. So any bit operation on integer larger than 2^32-1 inside JS would cause issue.
The text was updated successfully, but these errors were encountered: