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

Fails on decoding large Double #26

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

Fails on decoding large Double #26

VasilyKrainov opened this issue Jul 15, 2022 · 0 comments

Comments

@VasilyKrainov
Copy link

This code makes the exception:

let str = "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
let data = str.data(using: .utf8)!
let decoder = CleanJSONDecoder()
do {
  let value = try decoder.decode(Double.self, from: data)
  print("OK = \(value)")
} catch {
  print("Error = \(error)")
}

If you remove one of zeroes in "str" 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