ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4290629052
> Could you add a test to cover it, and is there any code example to
reproduce it?
@chaokunyang this may reproduce the bug and also show the verification of
the fix
```dart
void main() {
const value = 3000000000; // positive, fits in JS safe-integer range
// Old (buggy) web fallback — value >> 63 is evaluated as a 32-bit int:
// 3000000000 as int32 == -1294967296 (bit 31 set → negative)
// -1294967296 >> 63 == -1 (fills with sign bit)
final buggyZigZag = (BigInt.from(value) << 1) ^ BigInt.from(value >> 63);
print(buggyZigZag); // Web: large negative number — CORRUPT
// Native: 6000000000 — correct (native >> is 64-bit)
// Fixed path — shift the BigInt, no truncation:
final signed = BigInt.from(value);
final fixedZigZag = (signed << 1) ^ (signed >> 63);
print(fixedZigZag); // Always: 6000000000 — correct on both platforms
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]