ln.objects/catalog/ODBDouble.cs

29 lines
734 B
C#

using System;
namespace ln.objects.catalog
{
public class ODBDouble : ODBValue
{
public ODBDouble(double value)
:base(0x18,value)
{}
public override byte[] Serialize() => BitConverter.GetBytes((double)Value);
protected override int compare(ODBEntity other)
{
double a = (double)Value;
double b = (double)(other as ODBValue).Value;
if (Math.Abs(a - b) < double.Epsilon)
return 0;
if (a < b)
return -1;
return 1;
}
static ODBDouble()
{
RegisterDeserializer(0x0018, (b, o, l) => new ODBDouble(BitConverter.ToDouble(b, o)));
}
}
}