当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.ClearBit方法代码示例

本文整理汇总了C#中BigInteger.ClearBit方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.ClearBit方法的具体用法?C# BigInteger.ClearBit怎么用?C# BigInteger.ClearBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigInteger的用法示例。


在下文中一共展示了BigInteger.ClearBit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestClearBit

        public void TestClearBit()
        {
            Assert.AreEqual(Zero, Zero.ClearBit(0));
            Assert.AreEqual(Zero, One.ClearBit(0));
            Assert.AreEqual(Two, Two.ClearBit(0));

            Assert.AreEqual(Zero, Zero.ClearBit(1));
            Assert.AreEqual(One, One.ClearBit(1));
            Assert.AreEqual(Zero, Two.ClearBit(1));

            // TODO Tests for clearing bits in negative numbers

            // TODO Tests for clearing extended bits

            for (int i = 0; i < 10; ++i)
            {
                var n = new BigInteger(128, Rnd);

                for (int j = 0; j < 10; ++j)
                {
                    int pos = Rnd.Next(128);
                    BigInteger m = n.ClearBit(pos);
                    bool test = m.ShiftRight(pos).Remainder(Two).Equals(One);

                    Assert.IsFalse(test);
                }
            }

            for (int i = 0; i < 100; ++i)
            {
                BigInteger pow2 = One.ShiftLeft(i);
                BigInteger minusPow2 = pow2.Negate();

                Assert.AreEqual(Zero, pow2.ClearBit(i));
                Assert.AreEqual(minusPow2.ShiftLeft(1), minusPow2.ClearBit(i));

                BigInteger bigI = BigInteger.ValueOf(i);
                BigInteger negI = bigI.Negate();

                for (int j = 0; j < 10; ++j)
                {
                    string data = "i=" + i + ", j=" + j;
                    Assert.AreEqual(bigI.AndNot(One.ShiftLeft(j)), bigI.ClearBit(j), data);
                    Assert.AreEqual(negI.AndNot(One.ShiftLeft(j)), negI.ClearBit(j), data);
                }
            }
        }
开发者ID:ChemicalRocketeer,项目名称:BigMath,代码行数:47,代码来源:BigIntegerTest.cs

示例2: ClearBit_pos_outside

 public void ClearBit_pos_outside()
 {
     BigInteger x = new BigInteger(1, 0xFFFF0000, 0xFFFF0000);
     BigInteger y = x.ClearBit(99);
     Expect(y, SameAs(x));
 }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:6,代码来源:BigIntegerTests.cs

示例3: ClearBit_pos_inside_initial_set

 public void ClearBit_pos_inside_initial_set()
 {
     BigInteger x = new BigInteger(1, 0xFFFF0000, 0xFFFF0000);
     BigInteger w = new BigInteger(1, 0xFEFF0000, 0xFFFF0000);
     BigInteger y = x.ClearBit(56);
     Expect(y == w);
 }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:7,代码来源:BigIntegerTests.cs

示例4: ClearBit_pos_inside_initial_clear

 public void ClearBit_pos_inside_initial_clear()
 {
     BigInteger x = new BigInteger(1, 0xFFFF0000, 0xFFFF0000);
     BigInteger y = x.ClearBit(39);
     Expect(y, SameAs(x));
 }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:6,代码来源:BigIntegerTests.cs

示例5: ClearBit_neg_outside

 public void ClearBit_neg_outside()
 {
     BigInteger x = new BigInteger(-1, 0xFFFF0000, 0xFFFF0000);
     BigInteger y = x.ClearBit(99);
     Expect(SameValue(y, -1, new uint[] { 8, 0, 0xFFFF0000, 0xFFFF0000 }));
 }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:6,代码来源:BigIntegerTests.cs

示例6: ClearBit_neg_inside_initial_set

 public void ClearBit_neg_inside_initial_set()
 {
     BigInteger x = new BigInteger(-1, 0xFFFF0000, 0xFFFF0000);
     BigInteger y = x.ClearBit(39);
     Expect(SameValue(y, -1, new uint[] { 0xFFFF0080, 0xFFFF0000 }));
 }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:6,代码来源:BigIntegerTests.cs


注:本文中的BigInteger.ClearBit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。