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

Decode BinaryInteger types from Doubles when exactly represented #7

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

swhitty
Copy link
Owner

@swhitty swhitty commented Jun 26, 2024

Allows any BinaryInteger type to be decoded from a floating point values that do no contain decimal places.

For example, the following now decodes:

// [10, 20, -30]
let values = try KeyValueDecoder().decode([Int].self, from: [10, 20.0, -30.0])

But the following throws an error:

// throws DecodingError.typeMismatch 'Double at SELF[1], cannot be exactly represented by Int'
let values = try KeyValueDecoder().decode([Int].self, from: [10, 20.5, -30.0])

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (91665a2) to head (556379a).

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #7   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          605       611    +6     
=========================================
+ Hits           605       611    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swhitty swhitty merged commit 258299e into main Jun 26, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants