Esempio n. 1
0
        public void TestUInt32()
        {
            var    b     = sizeof(UInt32) * 8 - 1;
            var    start = unchecked ((UInt32)(UInt32)1 << b);
            UInt32 v     = start;

            for (var i = 0; i < (sizeof(UInt32) * 8) - 1; i++)
            {
                v.Ror();
                var a = (UInt32)((UInt32)1 << (b - 1 - i));
                _output?.WriteLine(Convert.ToString(a, 2).PadLeft(32, '0') + " == " + Convert.ToString(v, 2).PadLeft(32, '0'));
                Assert.Equal(a, v);
            }

            v.Ror();
            _output?.WriteLine(Convert.ToString(start, 2).PadLeft(32, '0') + " == " + Convert.ToString((UInt32)((UInt32)v), 2).PadLeft(32, '0'));
            Assert.Equal((UInt32)start, (UInt32)(UInt32)v);
        }
Esempio n. 2
0
 public void TestUInt32()
 {
     for (var i = 0; i < (sizeof(UInt32) * 8); i++)
     {
         var    b = sizeof(UInt32) * 8 - 1;
         UInt32 v = unchecked ((UInt32)(UInt32)1 << b);
         v.Ror(i);
         var a = (UInt32)((UInt32)1 << (b - i));
         _output?.WriteLine(Convert.ToString(a, 2).PadLeft(32, '0') + " == " + Convert.ToString(v, 2).PadLeft(32, '0'));
         Assert.Equal(a, v);
     }
 }