Skip to content

Commit a4a5033

Browse files
authored
Merge pull request scala/scala#10930 from tanishiking/fix-bigint-testbit
Fix `BigInt#testBit` to throw `ArithmeticException` when `n` is negative
2 parents d5cf2d8 + f4e7bcf commit a4a5033

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/scala/math/BigInt.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ final class BigInt private (private var _bigInteger: BigInteger, private val _lo
379379
else if (_long < 0) BigInt(-1)
380380
else BigInt(0) // for _long >= 0
381381
} else BigInt(this.bigInteger.shiftRight(n))
382-
382+
383383
/** Bitwise and of BigInts
384384
*/
385385
def &(that: BigInt): BigInt =
@@ -501,7 +501,7 @@ final class BigInt private (private var _bigInteger: BigInteger, private val _lo
501501
(_long & (1L << n)) != 0
502502
else
503503
_long < 0 // give the sign bit
504-
} else _bigInteger.testBit(n)
504+
} else this.bigInteger.testBit(n)
505505

506506
/** Returns a BigInt whose value is equivalent to this BigInt with the designated bit set.
507507
*/

0 commit comments

Comments
 (0)