diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-30 15:33:18 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-30 15:33:18 +0700 |
commit | 5e0b449eae68f6adf1f988f9601a299f3aa6c468 (patch) | |
tree | cc622c2de05cd5bd27f1044b6bb614c520d2cd7e /crypto/src/util/Integers.cs | |
parent | EdDSA updates (diff) | |
download | BouncyCastle.NET-ed25519-5e0b449eae68f6adf1f988f9601a299f3aa6c468.tar.xz |
Misc. updates from bc-java
Diffstat (limited to 'crypto/src/util/Integers.cs')
-rw-r--r-- | crypto/src/util/Integers.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/src/util/Integers.cs b/crypto/src/util/Integers.cs index bd05a053e..afb4b827f 100644 --- a/crypto/src/util/Integers.cs +++ b/crypto/src/util/Integers.cs @@ -19,6 +19,20 @@ namespace Org.BouncyCastle.Utilities return n; } + public static int NumberOfTrailingZeros(int i) + { + if (i == 0) + return 32; + + int count = 0; + while ((i & 1) == 0) + { + i >>= 1; + ++count; + } + return count; + } + public static int RotateLeft(int i, int distance) { return (i << distance) ^ (int)((uint)i >> -distance); |