public static void WriteCompressedDecimal(this IWriteBytes stream, decimal value) { value = value / 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000m; var bits = decimal.GetBits(value); stream.WriteCompressedInt(bits[0]); stream.WriteCompressedInt(bits[1]); stream.WriteCompressedInt(bits[2]); stream.WriteCompressedInt(bits[3]); }
public static void WriteDoubleOffset(this IWriteBytes stream, double seed, double tickSize, double value) { if (value == seed) { /// Since this is true 80% of the time in a trading platform, we use this optimization for significant performance gains. stream.WriteCompressedInt(0); } else { stream.WriteCompressedInt(ToTicks(value - seed, tickSize)); } }
public static void WriteCompressedNullableInt(this IWriteBytes stream, int?value) { if (value.HasValue) { stream.WriteCompressedBool(true); stream.WriteCompressedInt(value.Value); } else { stream.WriteCompressedBool(false); } }
public static void WriteCompressedEnum <T>(this IWriteBytes stream, T value) where T : Enum { stream.WriteCompressedInt((int)(object)value); }