Added byte[].GetSingle() and byte[].GetDouble()
ln.build - build0.waldrennach.l--n.de build job pending Details

master
Harald Wolff 2020-12-12 17:56:15 +01:00
parent b7a64b4609
commit 8bd39c3cc3
1 changed files with 16 additions and 0 deletions

View File

@ -62,6 +62,22 @@ namespace ln.type
}
public static uint GetUInt(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToUInt32(bytes.Slice(ref offset, 4).To(endianess), 0);
public static byte[] GetSingle(this byte[] bytes, ref int offset, out float value) => GetSingle(bytes, ref offset, out value, Endianess.LITTLE);
public static byte[] GetSingle(this byte[] bytes, ref int offset, out float value, Endianess endianess)
{
value = GetSingle(bytes, ref offset, endianess);
return bytes;
}
public static float GetSingle(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToSingle(bytes.Slice(ref offset, 4).To(endianess), 0);
public static byte[] GetDouble(this byte[] bytes, ref int offset, out double value) => GetDouble(bytes, ref offset, out value, Endianess.LITTLE);
public static byte[] GetDouble(this byte[] bytes, ref int offset, out double value, Endianess endianess)
{
value = GetDouble(bytes, ref offset, endianess);
return bytes;
}
public static double GetDouble(this byte[] bytes, ref int offset, Endianess endianess) => BitConverter.ToDouble(bytes.Slice(ref offset, 8).To(endianess), 0);
public static byte[] GetBytes(this byte[] bytes,ref int offset,int length,out byte[] value)
{