/// <summary> /// 弹出一个long /// </summary> /// <returns></returns> public long PopLong() { var buf = new byte[8]; Pop(buf); return(ByteUtil.ToLong(buf, 0, NetOrder())); }
/// <summary> /// 获取pos位置的long值 /// </summary> /// <param name="pos"></param> /// <returns></returns> public long GetLong(int pos) { var buf = new byte[8]; Get(pos, buf); return(ByteUtil.ToLong(buf, 0, NetOrder())); }
/// <summary> /// 随机长整数 /// </summary> public static long RandomLong(this Random self, DigitSign sign = DigitSign.All) { var bytes = new byte[8]; self.NextBytes(bytes); if (sign == DigitSign.Positive) { bytes[0] = 0; //非负 } else if (sign == DigitSign.Negative) { bytes[0] = 1; //非负 } return(ByteUtil.ToLong(bytes)); }
public static long ReadLong(this Stream stream) { var data = new byte[8]; return(ByteUtil.ToLong(Read(stream, data))); }
/// <summary> /// 在末尾添加double类型的value /// </summary> /// <param name="value"></param> /// <returns></returns> public void AppendDouble(double value) { AppendLong(ByteUtil.ToLong(value.ToBytes())); }
/// <summary> /// 在pos位置设置double类型的value /// </summary> /// <param name="pos"></param> /// <param name="value"></param> /// <returns></returns> public void SetDouble(int pos, double value) { SetLong(pos, ByteUtil.ToLong(value.ToBytes())); }
/// <summary> /// 获取一个long类型的数据 /// </summary> /// <returns></returns> public long GetLong() { var data = GetData(8); return(ByteUtil.ToLong(data)); }