예제 #1
0
        public void Abs()
        {
            // abs(int)
            const int ip1 = 1;
            const int in1 = -1;

            Cmpr(Fast.Abs(ip1), Def.Abs(ip1), "Abs(1)");
            Cmpr(Fast.Abs(in1), Def.Abs(in1), "Abs(-1)");
            Cmpr(Fast.Abs(int.MaxValue), Def.Abs(int.MaxValue), "Abs(int.max)");
            Cmpr(Fast.Abs(int.MaxValue - 1), Def.Abs(int.MaxValue - 1), "Abs(int.max-1)");
            Cmpr(Fast.Abs(int.MinValue + 1), Def.Abs(int.MinValue + 1), "Abs(int.min+1)");

            //abs(long)
            const long lp1 = 1;
            const long ln1 = -1;

            Cmpr(Fast.Abs(lp1), Def.Abs(lp1), "Abs(1L)");
            Cmpr(Fast.Abs(ln1), Def.Abs(ln1), "Abs(-1L)");
            Cmpr(Fast.Abs(long.MaxValue), Def.Abs(long.MaxValue), "Abs(long.max)");
            Cmpr(Fast.Abs(long.MaxValue - 1L), Def.Abs(long.MaxValue - 1L), "Abs(long.max-1)");
            Cmpr(Fast.Abs(long.MinValue + 1L), Def.Abs(long.MinValue + 1L), "Abs(long.min+1)");

            //abs(short)
            const short sp1 = 1;
            const short sn1 = -1;

            Cmpr(Fast.Abs(sp1), Def.Abs(sp1), "Abs(1s)");
            Cmpr(Fast.Abs(sn1), Def.Abs(sn1), "Abs(-1s)");
            Cmpr(Fast.Abs(short.MaxValue), Def.Abs(short.MaxValue), "Abs(short.max)");
            Cmpr(Fast.Abs((short)(short.MaxValue - 1)), Def.Abs((short)(short.MaxValue - 1)), "Abs(short.max-1)");
            Cmpr(Fast.Abs((short)(short.MinValue + 1)), Def.Abs((short)(short.MinValue + 1)), "Abs(short.min+1)");

            //abs(sbyte)
            const sbyte bp1 = 1;
            const sbyte bn1 = -1;

            Cmpr(Fast.Abs(bp1), Def.Abs(bp1), "Abs(1b)");
            Cmpr(Fast.Abs(bn1), Def.Abs(bn1), "Abs(-1b)");
            Cmpr(Fast.Abs(sbyte.MaxValue), Def.Abs(sbyte.MaxValue), "Abs(sbyte.max)");
            Cmpr(Fast.Abs((sbyte)(sbyte.MaxValue - 1)), Def.Abs((sbyte)(sbyte.MaxValue - 1)), "Abs(sbyte.max-1)");
            Cmpr(Fast.Abs((sbyte)(sbyte.MinValue + 1)), Def.Abs((sbyte)(sbyte.MinValue + 1)), "Abs(sbyte.min+1)");
        }