Fix signum implementation#280
Merged
JordanMartinez merged 12 commits intopurescript:masterfrom Mar 16, 2022
JordanMartinez:fix-signum
Merged
Fix signum implementation#280JordanMartinez merged 12 commits intopurescript:masterfrom JordanMartinez:fix-signum
JordanMartinez merged 12 commits intopurescript:masterfrom
JordanMartinez:fix-signum
Conversation
hdgarrood
reviewed
Mar 2, 2022
hdgarrood
reviewed
Mar 2, 2022
hdgarrood
reviewed
Mar 2, 2022
Co-authored-by: Harry Garrood <harry@garrood.me>
Co-authored-by: Harry Garrood <harry@garrood.me>
triallax
reviewed
Mar 3, 2022
hdgarrood
reviewed
Mar 3, 2022
test/Test/Main.purs
Outdated
| testSignum :: AlmostEff | ||
| testSignum = do | ||
| assert "signum positive zero" $ signum 0.0 == 0.0 | ||
| assert "signum negative zero" $ signum (-0.0) == (-0.0) |
Contributor
There was a problem hiding this comment.
This doesn't work unfortunately - positive zero compares equal to negative zero. Maybe try show-ing the result?
Contributor
Author
There was a problem hiding this comment.
Changing the test to
assert ("signum negative zero: " <> show (signum (-0.0))) $ show (signum (-0.0)) == "-0.0"produces this error:
Error: signum negative zero: 0.0
Contributor
Author
There was a problem hiding this comment.
And assert (show (-0.0)) $ false produces Error: 0.0
Contributor
Author
There was a problem hiding this comment.
Looks like Object.is is a way to verify this.
hdgarrood
reviewed
Mar 3, 2022
Co-authored-by: Harry Garrood <harry@garrood.me>
hdgarrood
reviewed
Mar 3, 2022
test/Test/Main.purs
Outdated
| assert "signum positive zero" $ objectIs (signum 0.0) 0.0 | ||
| assert "signum negative zero" $ objectIs (signum (-0.0)) (-0.0) | ||
|
|
||
| -- Seems to be only way to check whether zero is `-0.0` or `0.0` |
Contributor
There was a problem hiding this comment.
I forgot that our show doesn't distinguish negative and positive zero. But, you can still distinguish them without the FFI:
show (1.0/0.0) == "Infinity"
show (1.0/(-0.0)) == "-Infinity"
Contributor
Author
thomashoneyman
approved these changes
Mar 16, 2022
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.
Description of the change
Fixes #263. This is a breaking change that shouldn't be merged until we start the v0.15.x release cycle.
Checklist: