Decimal support?


Is there any plan to support ‘decimal’? (or BigDecimal in java)
As you know it is an important variable type used in accounting systems, and using long or byte array is not a good idea!


Yes - we have an open issue in our backlog, but that hasn’t been prioritized as we haven’t received many requests for supporting it.


Really? I think most people already stop considering realm in the first place, “because” there is no support for decimal!


Certainly is important for us! If it’s of any help to anyone we implement decimals like this

private double _ItemCost { get; set; }
public decimal ItemCost
    get => (decimal)Math.Round(_ItemCost, 2);
    set => _ItemCost = Math.Round((double)value, 2);

Please let me know if anyone thinks this is dumb :slight_smile:


Decimal gets my vote too.

BTW, since you are prioritizing things also according to people requests, maybe it would be nice to create some kind of poll, so people can vote?


You can upvote on the GitHub link


It’s not ideal, but one way you can work around it for now is like this:

class MyObject : RealmObject
    public decimal DecimalValue
            var bits = new[]

            return new decimal(bits);
            var bits = decimal.GetBits(value);
            Decimal_0 = bits[0];
            Decimal_1 = bits[1];
            Decimal_2 = bits[2];
            Decimal_3 = bits[3];

            DoubleValue = decimal.ToDouble(value);

    public double DoubleValue { get; private set; }

    private int Decimal_0 { get; set; }
    private int Decimal_1 { get; set; }
    private int Decimal_2 { get; set; }
    private int Decimal_3 { get; set; }

This way you store the decimal precisely in the 4 integer components, yet you have its double approximation, which should help for querying (because querying by the int components would be quite cumbersome).