GetLowestSetBit() public method

public GetLowestSetBit ( ) : int
return int
コード例 #1
0
ファイル: BigIntegerTest.cs プロジェクト: randombit/hacrypto
		public void TestGetLowestSetBit()
		{
			for (int i = 0; i < 10; ++i)
			{
				BigInteger test = new BigInteger(128, 0, random).Add(one);
				int bit1 = test.GetLowestSetBit();
				Assert.AreEqual(test, test.ShiftRight(bit1).ShiftLeft(bit1));
				int bit2 = test.ShiftLeft(i + 1).GetLowestSetBit();
				Assert.AreEqual(i + 1, bit2 - bit1);
				int bit3 = test.ShiftLeft(13 * i + 1).GetLowestSetBit();
				Assert.AreEqual(13 * i + 1, bit3 - bit1);
			}
		}