Large addition tests added

This commit is contained in:
zhelenskiy 2021-05-12 13:59:41 +03:00
parent ded01251d1
commit 1e71f29d5e
2 changed files with 11 additions and 1 deletions

View File

@ -32,6 +32,16 @@ internal class BigIntBenchmark {
blackhole.consume(jvmNumber + jvmNumber + jvmNumber) blackhole.consume(jvmNumber + jvmNumber + jvmNumber)
} }
@Benchmark
fun kmAddLarge(blackhole: Blackhole) = BigIntField {
blackhole.consume(largeKmNumber + largeKmNumber + largeKmNumber)
}
@Benchmark
fun jvmAddLarge(blackhole: Blackhole) = JBigIntegerField {
blackhole.consume(largeJvmNumber + largeJvmNumber + largeJvmNumber)
}
@Benchmark @Benchmark
fun kmMultiply(blackhole: Blackhole) = BigIntField { fun kmMultiply(blackhole: Blackhole) = BigIntField {
blackhole.consume(kmNumber * kmNumber * kmNumber) blackhole.consume(kmNumber * kmNumber * kmNumber)

View File

@ -281,7 +281,7 @@ public class BigInt internal constructor(
} }
result[i] = (res and BASE).toUInt() result[i] = (res and BASE).toUInt()
carry = (res shr BASE_SIZE) carry = res shr BASE_SIZE
} }
result[resultLength - 1] = carry.toUInt() result[resultLength - 1] = carry.toUInt()