mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
js: optimize long operations
This commit is contained in:
parent
154bf7abd9
commit
edf2d33f84
|
@ -852,13 +852,14 @@ if (typeof BigInt !== "function") {
|
||||||
} else {
|
} else {
|
||||||
Long_ZERO = BigInt(0);
|
Long_ZERO = BigInt(0);
|
||||||
Long_create = function(lo, hi) {
|
Long_create = function(lo, hi) {
|
||||||
return BigInt.asIntN(64, BigInt.asUintN(32, BigInt(lo)) | (BigInt(hi) << BigInt(32)));
|
return BigInt.asIntN(64, BigInt.asUintN(64, BigInt(lo))
|
||||||
|
| BigInt.asUintN(64, (BigInt(hi) << BigInt(32))));
|
||||||
}
|
}
|
||||||
Long_fromInt = function(val) {
|
Long_fromInt = function(val) {
|
||||||
return BigInt(val);
|
return BigInt.asIntN(64, BigInt(val | 0));
|
||||||
}
|
}
|
||||||
Long_fromNumber = function(val) {
|
Long_fromNumber = function(val) {
|
||||||
return BigInt(val >= 0 ? Math.floor(val) : Math.ceil(val));
|
return BigInt.asIntN(64, BigInt(val >= 0 ? Math.floor(val) : Math.ceil(val)));
|
||||||
}
|
}
|
||||||
Long_toNumber = function(val) {
|
Long_toNumber = function(val) {
|
||||||
return Number(val);
|
return Number(val);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user