Space Age: Don't compare floats using ==#103
Merged
kytrinyx merged 1 commit intoexercism:masterfrom Mar 28, 2015
Merged
Conversation
It's bad form to compare floats with each other using == and Exercism shouldn't be showing this to aspiring programmers. [The standard lib docs says](http://ruby-doc.org/stdlib-1.9.2/libdoc/minitest/unit/rdoc/MiniTest/Assertions.html#method-i-assert_in_delta) that `asset_in_delta` should be used to compare floats. The modified test pass with code designed for the old test (i.e. with `round(2)` after the division) and allows new code not to have to round the division which feels unnatural (it should not a responsibility of `SpaceAge` to round its output).
Member
|
Yes, this is a definite improvement. Thanks! |
kytrinyx
added a commit
that referenced
this pull request
Mar 28, 2015
Space Age: Don't compare floats using ==
kytrinyx
added a commit
that referenced
this pull request
Mar 31, 2015
Space Age: Don't compare floats using ==
gchan
pushed a commit
to gchan/xruby
that referenced
this pull request
Oct 18, 2016
Added core set of test cases for word-count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's bad form to compare floats with each other using == and Exercism shouldn't be showing this to aspiring programmers.
As the standard lib docs says
asset_in_deltashould be used to compare floats.The modified test pass with code designed for the old test (i.e. with
round(2)after the division) and allows new code not to have to round the division which feels unnatural (it should not a responsibility ofSpaceAgeto round its output).