コード例 #1
0
ファイル: GeneralMathTests.cs プロジェクト: AlFasGD/Garyon
        public void Power()
        {
            Assert.AreEqual(0, GeneralMath.Power(5, -1));
            Assert.AreEqual(0L, GeneralMath.Power(5L, -1));

            Assert.AreEqual(0, GeneralMath.Power(0, 5));
            Assert.AreEqual(0, GeneralMath.Power(0, 1));
            Assert.Throws <InvalidOperationException>(() => GeneralMath.Power(0, 0));

            Assert.AreEqual(0L, GeneralMath.Power(0L, 5));
            Assert.AreEqual(0L, GeneralMath.Power(0L, 1));
            Assert.Throws <InvalidOperationException>(() => GeneralMath.Power(0L, 0));

            for (int b = 1; b < 5; b++)
            {
                int currentBase = 1;

                for (int exponent = 0; exponent < 16; exponent++)
                {
                    Assert.AreEqual(currentBase, GeneralMath.Power(b, exponent));
                    Assert.AreEqual((long)currentBase, GeneralMath.Power((long)b, exponent));
                    currentBase *= b;
                }
            }
        }
コード例 #2
0
ファイル: Power.cs プロジェクト: AlFasGD/Garyon
 public void CustomPowerInt64()
 {
     GeneralMath.Power(Base, (long)Exponent);
 }
コード例 #3
0
ファイル: Power.cs プロジェクト: AlFasGD/Garyon
 public void CustomPowerInt32()
 {
     GeneralMath.Power(Base, Exponent);
 }