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

fuzzier json number equatable #42

Merged
merged 2 commits into from
May 26, 2016
Merged

Conversation

loganwright
Copy link
Contributor

One potential implementation of fuzzier json number equality. When creating a double, I don't know how to check if below Double max similar to others if someone has suggestions.

@loganwright loganwright mentioned this pull request May 26, 2016
private var uint: UInt? {
switch self {
case let .double(d) where d >= 0:
return UInt(d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this cut the floating point part of the number?

let d = 2.1
UInt(d) //2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you'd be comparing UInt(2) and Double(2.1), it'd return true. That doesn't seem right

@loganwright
Copy link
Contributor Author

@czechboy0 totally right, just updated!

@czechboy0
Copy link
Contributor

Cool, just left one comment for something that I think should be fixed. Once that's done I'll merge, thanks @loganwright! (Even though it's not 100% correct (Int.max gets cut when converted to Double), but 99.99% might be good enough here, it definitely is easier to use)

@czechboy0 czechboy0 merged commit 4f76ccc into hd/json-equatable May 26, 2016
@czechboy0 czechboy0 deleted the lw/json-number-equatable branch May 26, 2016 19:47
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