Commit 286db316 authored by John Zhang's avatar John Zhang

fix: construct BigInt with lower bit first

parent 39bb004b
...@@ -24,8 +24,10 @@ object IRBuilderCommInstExecutor { ...@@ -24,8 +24,10 @@ object IRBuilderCommInstExecutor {
def unsignedLongSeqToBigInt(nums: Seq[Long]): BigInt = { def unsignedLongSeqToBigInt(nums: Seq[Long]): BigInt = {
var bigNum = BigInt(0) var bigNum = BigInt(0)
var i = 0
for (num <- nums) { for (num <- nums) {
bigNum = (bigNum << 64) | (BigInt(num) & 0xffffffffffffffffL) bigNum = bigNum | ((BigInt(num) & 0xffffffffffffffffL) << 64 * i)
i += 1
} }
bigNum bigNum
} }
......
...@@ -22,13 +22,15 @@ object NativeMemoryAccessHelper { ...@@ -22,13 +22,15 @@ object NativeMemoryAccessHelper {
val str = theMemory.getString(base, len.toInt, StandardCharsets.US_ASCII) val str = theMemory.getString(base, len.toInt, StandardCharsets.US_ASCII)
str str
} }
def unsignedLongSeqToBigInt(nums: Seq[Long]): BigInt = { def unsignedLongSeqToBigInt(nums: Seq[Long]): BigInt = {
var bigNum = BigInt(0) var bigNum = BigInt(0)
for (num <- nums) { var i = 0
bigNum = (bigNum << 64) | (BigInt(num) & 0xffffffffffffffffL) for (num <- nums) {
} bigNum = bigNum | ((BigInt(num) & 0xffffffffffffffffL) << 64 * i)
bigNum i += 1
}
bigNum
} }
def readIntArray(base: Long, len: Long): IndexedSeq[Int] = { def readIntArray(base: Long, len: Long): IndexedSeq[Int] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment