I have a Realm Sync schema that specifies a field called performance
with "bsonType": "decimal"
. In Swift, that gets turned into a Decimal128
.
Sometimes, the value I store in this field is actually an integer.
I have discovered that I can convert from Int
to Decimal128
by using Decimal128(integerLiteral: Int64(intValue))
- which feels a bit clumsy, but at least it works.
I have no idea how to turn my Decimal128
value back into an Int
. (Except maybe by going via a String
… surely not?!)
What is the proper way to convert a Decimal128
value to and from an Int
value in Swift?
Thanks!