Exemplo n.º 1
0
        private long GetDiplomacyKey(int first, int second)
        {
            LongUnion value = new LongUnion();

            value.Set(first, second);
            return(value.Key);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void TestGetLowWord()
        {
            Assert.That(0x0FABBEEFL.GetLowInt(), Is.EqualTo(0x0FABBEEF));
            Assert.That((-0x0FABBEEFL).GetLowInt(), Is.EqualTo(-0x0FABBEEF));

            Assert.That(0x0FABBEEF0CAFDEAD.GetLowInt(), Is.EqualTo(0x0CAFDEAD));
            Assert.That((-0x0FABBEEF0CAFDEAD).GetLowInt(), Is.EqualTo(-0x0CAFDEAD));

            LongUnion confirm = new LongUnion {
                Number = -0x0FABBEEFFEEDDEAD
            };

            Assert.That((-0x0FABBEEFFEEDDEAD).GetLowInt(), Is.EqualTo(confirm.Low));
        }
Exemplo n.º 4
0
        public void TestGetHighWord()
        {
            Assert.That(0x0FABBEEFL.GetHighInt(), Is.EqualTo(0));
            Assert.That((-0x0FABBEEFL).GetHighInt(), Is.EqualTo(-1));

            Assert.That(0x0FABBEEFFEEDDEAD.GetHighInt(), Is.EqualTo(0x0FABBEEF));
            Assert.That((-0x0FABBEEFFEEDDEAD).GetHighInt(), Is.EqualTo(-0xFABBEF0));

            LongUnion confirm = new LongUnion {
                Number = -0x0FABBEEFFEEDDEAD
            };

            Assert.That((-0x0FABBEEFFEEDDEAD).GetHighInt(), Is.EqualTo(confirm.High));
        }
        public static void Write(BitStream stream, long value)
        {
            var union = new LongUnion {
                Value = value
            };

            Write(stream, union.byte0);
            Write(stream, union.byte1);
            Write(stream, union.byte2);
            Write(stream, union.byte3);
            Write(stream, union.byte4);
            Write(stream, union.byte5);
            Write(stream, union.byte6);
            Write(stream, union.byte7);
        }
        public static void Write(ref byte[] bytes, ref int offset, long value)
        {
            var union = new LongUnion {
                Value = value
            };

            Write(ref bytes, ref offset, union.byte0);
            Write(ref bytes, ref offset, union.byte1);
            Write(ref bytes, ref offset, union.byte2);
            Write(ref bytes, ref offset, union.byte3);
            Write(ref bytes, ref offset, union.byte4);
            Write(ref bytes, ref offset, union.byte5);
            Write(ref bytes, ref offset, union.byte6);
            Write(ref bytes, ref offset, union.byte7);
        }