Skip to content
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

[js] Wrong calculation for Int64 (ushr / add) methods #11475

Open
flashultra opened this issue Jan 8, 2024 · 1 comment
Open

[js] Wrong calculation for Int64 (ushr / add) methods #11475

flashultra opened this issue Jan 8, 2024 · 1 comment

Comments

@flashultra
Copy link
Contributor

The following code return 547226893 ( 0x209E050D ) instead the correct one 4842194189 ( 0x1209E050D )
The problem is only for JS target ( https://try.haxe.org/#212E9Fb4 )

var i:Int64 = Int64.make(0xF0E3FF1B, 0x00000000);
var j:Int64 = Int64.make(0x2FBA05F2, 0x69D9E4DC);
var mcr:Int64 = Int64.ushr(i, 32);
var pcrm:Int64 = Int64.ushr(j, 32);
var result = Int64.add(mcr, pcrm);
trace("Result: " + result);
@flashultra
Copy link
Contributor Author

flashultra commented Jan 8, 2024

Generated JS code :

let i_high = -253493477;
let mcr_low = i_high >>> 0;
let pcrm_low = 800720370 >>> 0;
let low = mcr_low + pcrm_low | 0;

or let low = 4041473819 + 800720370 | 0;

If remove | 0 the result is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant