From b7cd34eda4a72102e119a373e3efa54c07d8b489 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 23 Mar 2007 18:01:41 +0000 Subject: Fixed ArrayIndexOutOfBounds in cached bigints f... Fixed ArrayIndexOutOfBounds in cached bigints for negative numbers. --- src/library/scala/BigInt.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala index 09f5fa08f2..0878d0d7aa 100644 --- a/src/library/scala/BigInt.scala +++ b/src/library/scala/BigInt.scala @@ -31,8 +31,9 @@ object BigInt { */ def apply(i: Int): BigInt = if (minCached <= i && i <= maxCached) { - var n = cache(i) - if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(i) = n } + val offset = i - minCached + var n = cache(offset) + if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(offset) = n } n } else new BigInt(BigInteger.valueOf(i)) -- cgit v1.2.3