Example #1
0
        public void WriteVarLong(double @double)
        {
            uint       local_3 = 0;
            FinalInt64 local_2 = FinalInt64.FromNumber(@double);

            if (local_2.High == 0)
            {
                WriteInt32((uint)local_2.Low);
            }
            else
            {
                local_3 = 0;
                while (local_3 < 4)
                {
                    WriteByte((byte)((uint)local_2.Low & 127 | 128));
                    local_2.Low = (long)local_2.Low >> 7;
                    local_3++;
                }
                if (((uint)local_2.High & 268435455 << 3) == 0)
                {
                    WriteByte((byte)((uint)local_2.High << 4 | (uint)local_2.Low));
                }
                else
                {
                    WriteByte((byte)(((uint)local_2.High << 4 | (uint)local_2.Low) & 127 | 128));
                    WriteInt32((uint)(local_2.High >> 3));
                }
            }
        }
        public FinalInt64 ReadVarInt64(BigEndianReader reader)
        {
            int        local_3 = 0;
            FinalInt64 local_2 = new FinalInt64();
            int        local_4 = 0;

            while (true)
            {
                local_3 = reader.ReadByte();
                if (local_4 == 28)
                {
                    break;
                }
                if (local_3 >= 128)
                {
                    local_2.Low = (uint)local_2.Low | (uint)((local_3 & 127) << local_4);
                    local_4    += 7;
                    continue;
                }
                local_2.Low = (uint)local_2.Low | (uint)(local_3 << local_4);
                return(local_2);
            }

            if (local_3 >= 128)
            {
                local_3      = local_3 & 127;
                local_2.Low  = (uint)local_2.Low | (uint)(local_3 << local_4);
                local_2.High = local_3 >> 4;
                local_4      = 3;

                while (true)
                {
                    local_3 = reader.ReadByte();
                    if (local_4 < 32)
                    {
                        if (local_3 >= 128)
                        {
                            local_2.High = local_2.High | (local_3 & 127) << local_4;
                        }
                        else
                        {
                            break;
                        }
                    }
                    local_4 += 7;
                }
                local_2.High = local_2.High | local_3 << local_4;
                return(local_2);
            }
            local_2.Low  = (int)local_2.Low | local_3 << local_4;
            local_2.High = local_3 >> 4;
            return(local_2);
        }