7

I received the following response from server

"transactionInfo": {
      "currencyCode": "MYR",
      "total": 472.23,
      "roomCurrencyCode": "MYR",
      "roomTotal": 472.23
}

but when I am trying to convert using SwiftyJson and map using below code

struct TransactionInfoModel: Codable {
   var currencyCode: String
   var total: Double
   var roomCurrencyCode: String
   var roomTotal: Double
}

then I get values like below:

"currencyCode": "MYR",
"total": 472.23000000000002,
"roomCurrencyCode": "MYR",
"roomTotal": 472.23000000000002

Please suggest how to resolve this issue. Thanks in advance.

Shiv Jaiswal
  • 539
  • 1
  • 6
  • 22

1 Answers1

-1

Swift uses the IEEE 754 standard for representing single- and double-precision.

swift: issue in converting string to double Marting has answered clearly your question.

Steven
  • 63
  • 5