public UInt64 ReadUInt64() { ulong low = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); m_readPosition += 32; ulong high = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); ulong retval = low + (high << 32); m_readPosition += 32; return(retval); }
public bool ReadInt32(out Int32 result) { if (m_bitLength - m_readPosition < 32) { result = 0; return(false); } result = (Int32)NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); m_readPosition += 32; return(true); }
public UInt64 PeekUInt64(int numberOfBits) { ulong retval; if (numberOfBits <= 32) { retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition); } else { retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32; } return(retval); }
/// <summary> /// Reads the specified number of bits into an Int32 without advancing the read pointer /// </summary> public Int32 PeekInt32(int numberOfBits) { uint retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition); if (numberOfBits == 32) { return((int)retval); } int signBit = 1 << (numberOfBits - 1); if ((retval & signBit) == 0) { return((int)retval); // positive } // negative unchecked { uint mask = ((uint)-1) >> (33 - numberOfBits); uint tmp = (retval & mask) + 1; return(-((int)tmp)); } }
public UInt32 PeekUInt32() { uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition); return(retval); }