After having a double variable initialized with 0.1 value and encoding it to JSON via SwiftyJSON I receive 0.10000000000000001 in JSON structure.
I'm aware of precision memory storage differences between float/double and integer but still I didn't found a quick fix for such situation besides using sprintf formatting like %.2f - I don't want to result with putting a string into json structure.
Any quick & easy solution to this will be appreciated.
I expect to have 0.1 value in JSON. If double value is 10 I expect value 10 in JSON. But how to avoid such precision-rounding errors during json encoding operation?
NSNumber
orDecimal
instead – Lakitalaks