diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-09 14:26:50 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-08-09 14:26:50 +0700 |
commit | e4f9374cbc49e000340836488666995e5cc3f23d (patch) | |
tree | fdc1cde55584b4286e8f64847937613cbb14e177 /crypto/src/math | |
parent | EdDSA refactoring (diff) | |
download | BouncyCastle.NET-ed25519-e4f9374cbc49e000340836488666995e5cc3f23d.tar.xz |
Add IntValueExact and LongValueExact to BigInteger
Diffstat (limited to 'crypto/src/math')
-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) { |