예제 #1
0
    public void V256_ShiftLeft()
    {
        Assert.AreEqual(
            new V256(
                192, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223,
                223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223),
            V256.FromByte(254) << 5);

        V256 x = new V256(
            255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
            239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224);

        Assert.AreEqual(
            "E0 DF BF 9F 7F 5F 3F 1F FF DE BE 9E 7E 5E 3E 1E FE DD BD 9D 7D 5D 3D 1D FD DC BC 9C 7C 5C 3C 1C",
            (x << 5).ToString());


        V256 y = new V256(
            0xF1, 0x18, 0x80, 0x01, 0x18, 0x80, 0x01, 0x18,
            0x80, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0x01,
            0x18, 0x80, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80,
            0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0xFF, 0x0F);

        Assert.AreEqual(
            "00 10 8F 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 F8",
            (y << 12).ToString());
    }
예제 #2
0
    public void V256_ShiftRight()
    {
        Assert.AreEqual(
            new V256(
                247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
                247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 7),
            V256.FromByte(254) >> 5);

        V256 x = new V256(
            255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
            239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224);

        Assert.AreEqual(
            "F7 EF E7 DF D7 CF C7 BF B7 AF A7 9F 97 8F 87 7F 77 6F 67 5F 57 4F 47 3F 37 2F 27 1F 17 0F 07 07",
            (x >> 5).ToString());

        V256 y = new V256(
            0xF1, 0x18, 0x80, 0x01, 0x18, 0x80, 0x01, 0x18,
            0x80, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0x01,
            0x18, 0x80, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80,
            0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0xFF, 0x0F);

        Assert.AreEqual(
            "01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 18 80 01 F8 FF 00 00",
            (y >> 12).ToString());
    }