diff --git a/static_core/plugins/ets/stdlib/escompat/BigInt.ets b/static_core/plugins/ets/stdlib/escompat/BigInt.ets index 66ef4fbb6117dad40b0daa08c9f7b2126ade6bd6..77a42f7711c566f39dd0227f1d575b99fc9a940a 100644 --- a/static_core/plugins/ets/stdlib/escompat/BigInt.ets +++ b/static_core/plugins/ets/stdlib/escompat/BigInt.ets @@ -754,10 +754,34 @@ export final class BigInt { } let limit:long = other.getLong() - for (let i:long = 0; i 0 ? 1 : 0); + let newBytes: FixedArray = new int[newLength]; + + if (bitShift > 0) { + let carry: int = 0; + let rightShift = wordSize - bitShift; + for (let i: int = 0; i < oldLength; i++) { + let currentWord: int = this.bytes[i]; + let newWord: int = ((currentWord << bitShift) | carry) & 0xFFFFFFFF; + carry = (currentWord >>> rightShift); + newBytes[i + wordShift] = newWord; + } + if (carry > 0) { + newBytes[newLength - 1] = carry; + } + } else { + copyTo(this.bytes, newBytes, wordShift, 0, oldLength); } - return new BigInt(lhs.bytes, lhs.sign) + + return new BigInt(newBytes, this.sign); + } public operatorRightShift(other: BigInt): BigInt {