I'm trying to find a way to handle decimals in mongodb. Is there any good way and/or should I handle it with a class like this:using System;public class MongoDecimal{    public long Value { get; set; }    public long SubValue { get; set; }    public long SubValueToValue { get; set; }    public decimal ToDecimal()    {        return Convert.ToDecimal(Value) + (Convert.ToDecimal(SubValue) / Convert.ToDecimal(SubValueToValue));    }    public override string ToString()    {        return ToDecimal().ToString();    }    public string ToString(IFormatProvider provider)    {        return ToDecimal().ToString(provider);    }    public string ToString(string format)    {        return ToDecimal().ToString(format);    }    public string ToString(string format, IFormatProvider provider)    {        return ToDecimal().ToString(format, provider);    }    public static MongoDecimal ToMongoDecimal(decimal value)    {        const long subValueToValue = 100000000;        return ToMongoDecimal(value, subValueToValue);    }    public static MongoDecimal ToMongoDecimal(decimal value, long subValueToValue)    {        var major = Math.Truncate(value);        var minor = Math.Truncate((value - major) * Convert.ToDecimal(subValueToValue));        return new MongoDecimal        {            Value = Convert.ToInt64(major),            SubValue = Convert.ToInt64(minor),            SubValueToValue = subValueToValue        };    }    public static MongoDecimal operator +(MongoDecimal value, MongoDecimal value2)    {        var right = SafeDecimal(value);        var left = SafeDecimal(value2);        return ToMongoDecimal(left.ToDecimal() + right.ToDecimal(), left.SubValueToValue >= right.SubValueToValue ? left.SubValueToValue : right.SubValueToValue);    }    public static MongoDecimal operator -(MongoDecimal value, MongoDecimal value2)    {        var right = SafeDecimal(value);        var left = SafeDecimal(value2);        return ToMongoDecimal(left.ToDecimal() - right.ToDecimal(), left.SubValueToValue >= right.SubValueToValue ? left.SubValueToValue : right.SubValueToValue);    }    public static MongoDecimal operator *(MongoDecimal value, MongoDecimal value2)    {        var right = SafeDecimal(value);        var left = SafeDecimal(value2);        return ToMongoDecimal(left.ToDecimal() * right.ToDecimal(), left.SubValueToValue >= right.SubValueToValue ? left.SubValueToValue : right.SubValueToValue);    }    public static MongoDecimal operator /(MongoDecimal value, MongoDecimal value2)    {        var right = SafeDecimal(value);        var left = SafeDecimal(value2);        if (right.Value == 0 && right.SubValue == 0)            throw new DivideByZeroException();        return ToMongoDecimal(left.ToDecimal() / right.ToDecimal(), left.SubValueToValue >= right.SubValueToValue ? left.SubValueToValue : right.SubValueToValue);    }    public static bool operator ==(MongoDecimal value, MongoDecimal value2)    {        if (value == null && value2 == null) return true;        if ((value == null && value2 != null) || (value != null && value2 == null)) return false;        return value.ToDecimal() == value2.ToDecimal();    }    public static bool operator !=(MongoDecimal value, MongoDecimal value2)    {        return !(value == value2);    }    public override bool Equals(object obj)    {        return this == (obj as MongoDecimal);    }    public override int GetHashCode()    {        unchecked        {            int hash = (int)2166136261;            hash = (hash * 1677619) ^ Value.GetHashCode();            hash = (hash * 1677619) ^ SubValue.GetHashCode();            hash = (hash * 1677619) ^ SubValueToValue.GetHashCode();            return hash;        }    }    public static MongoDecimal SafeDecimal(MongoDecimal d)    {        if (d != null)            return d;        return new MongoDecimal { SubValue = 0, Value = 0, SubValueToValue = 1 };    }}
Handle decimal in mongodb
c#;mongodb;fixed point