diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/math/BigInteger.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs index 36f30d7c0..3badb6d2c 100644 --- a/crypto/src/math/BigInteger.cs +++ b/crypto/src/math/BigInteger.cs @@ -1332,6 +1332,17 @@ namespace Org.BouncyCastle.Math } } + public int IntValueExact + { + get + { + if (BitLength > 31) + throw new ArithmeticException("BigInteger out of int range"); + + return IntValue; + } + } + /** * return whether or not a BigInteger is probably prime with a * probability of 1 - (1/2)**certainty. @@ -1588,6 +1599,17 @@ namespace Org.BouncyCastle.Math } } + public long LongValueExact + { + get + { + if (BitLength > 63) + throw new ArithmeticException("BigInteger out of long range"); + + return LongValue; + } + } + public BigInteger Max( BigInteger value) { |