public void Equality() { double original = 0.7286906838f; double maximum = 5f; var compressed = new CompressedNumber <double, Double, ushort, UShort>(original, maximum); var recompressed = new CompressedNumber <double, Double, ushort, UShort>(original, maximum); Assert.Equal(recompressed, compressed); }
public void CompressDouble() { double original = 0.7286906838f; double maximum = 5f; var compressed = new CompressedNumber <double, Double, ushort, UShort>(original, maximum); double decompressed = compressed.GetValue(maximum); Assert.Equal(original, decompressed, 5); }
public void CompressMinValue() { int original = short.MinValue; int maximum = short.MaxValue; var compressed = new CompressedNumber <int, Int, short, Short>(original, maximum); int decompressed = compressed.GetValue(maximum); Assert.Equal(original, decompressed); }
public void CompressFloat() { float original = 1.214814305f; float maximum = 5f; var compressed = new CompressedNumber <float, Float, ushort, UShort>(original, maximum); float decompressed = compressed.GetValue(maximum); Assert.Equal(original, decompressed, 4); }
public unsafe void IsBlittable() { // Requires C# 8. Please ignore if Intellisense complains. Will compile and run. double original = 0.7286906838f; double maximum = 5f; var compressed = new CompressedNumber <double, Double, ushort, UShort>(original, maximum); var bytes = Struct.GetBytes(compressed); Struct.FromArray(bytes, out CompressedNumber <double, Double, ushort, UShort> fromBytes, 0); var decompressed = fromBytes.GetValue(maximum); Assert.Equal(original, decompressed, 5); }