Example #1
0
        public static void UnionTest()
        {
            IntUnion foo = new IntUnion { Int = -1 };
            System.Console.WriteLine(foo.UInt);

            LongUnion bar = new LongUnion { Long = -1 };
            System.Console.WriteLine(bar.ULong);
        }
        public static void Write(ref byte[] bytes, ref int offset, int value)
        {
            var cc = new IntUnion {
                Value = value
            };

            /*            Write(ref bytes,ref offset, cc.byte0);
             *          Write(ref bytes,ref offset, cc.byte1);
             *          Write(ref bytes,ref offset, cc.byte2);
             *          Write(ref bytes,ref offset, cc.byte3);*/
        }
        public void TestGetLowWord()
        {
            // 0x0FABBEEF is [0000 1111 1010 1011][1011 1110 1110 1111]
            // -0x0FABBEEF is [1111 0000 0101 0100][0100 0001 0001 0001]
            Assert.That(0x0FABBEEF.GetLowWord(), Is.EqualTo(0xBEEF));
            Assert.That((-0x0FABBEEF).GetLowWord(), Is.EqualTo(0x4111));

            IntUnion confirm = new IntUnion {
                Number = -0x0FABBEEF
            };

            Assert.That((-0x0FABBEEF).GetLowWord(), Is.EqualTo(confirm.Low));
        }