Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding large Double #49

Open
VasilyKrainov opened this issue Jul 15, 2022 · 0 comments
Open

Decoding large Double #49

VasilyKrainov opened this issue Jul 15, 2022 · 0 comments

Comments

@VasilyKrainov
Copy link

This code makes the exception:

struct Response: Codable {
  let success: Bool
  let value: Double
}
func testJASON() {
  let string: String =
    """
    {"success":true,"value":100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000≥0}
    """
  let data = string.data(using: .utf8)!
  let json = JASON.JSON(data)
  let val = json["value"].double
  print("\(val)")
}

If you remove one of zeroes in "string" then the decoding will be OK. So the limit is 1e165, after which the decoding fails regardless of Double type can really fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant