Karatsuba added, 2 bugs are fixed #328
@ -254,6 +254,7 @@ public interface Ring<T> : Group<T>, RingOperations<T> {
|
||||
public fun T.pow(exponent: ULong): T = when {
|
||||
this == zero && exponent > 0UL -> zero
|
||||
this == one -> this
|
||||
this == -one -> powWithoutOptimization(exponent % 2UL)
|
||||
else -> powWithoutOptimization(exponent)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ internal class BigIntAlgebraTest {
|
||||
@Test
|
||||
fun testKBigIntegerRingPow() {
|
||||
BigIntField {
|
||||
for (num in 0..5)
|
||||
for (num in -5..5)
|
||||
for (exponent in 0UL..10UL)
|
||||
assertEquals(
|
||||
num.toDouble().pow(exponent.toInt()).toLong().toBigInt(),
|
||||
|
Loading…
Reference in New Issue
Block a user