Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use IEEE-style Rationals for ±Inf/NaN Num conversions
Fixes RT#130459: https://rt.perl.org/Ticket/Display.html?id=130459 Fixes RT#130171: https://rt.perl.org/Ticket/Display.html?id=130171 Fixes RT#128857: https://rt.perl.org/Ticket/Display.html?id=128857 Fix follows TimToady++'s recommendation: https://irclog.perlgeek.de/perl6-dev/2016-08-06#i_12976358 The best I could trace the history of changes that led to introduction of special Num-numerator Rationals is (in my eyes) a misunderstanding of TimToady's evals[^1] where along with conversion[^2] of ±Inf/NaN to Rational, they were made[^3] non-explosively stringifiable. That, in turn, made all division by zero non-explosive in Str view, so Num-numerator Rationals were introduced to fix that issue. The fix in this commit simply goes back to using ±1/0 numerators for ±Inf/NaN Rationals and have Str view explode for them (just as it does already for any other zero-denominator Rational). The decision to use ±1 numerator for Infs is deliberate as is NOT having .new() normalize numerators for zero-denominator Rationals to ±1, since that seems to me to just throw away information for no good reason. The result of that decision is that, for example, <42/0>.perl and <42/0>.Num.Rat.perl will differ, with the latter becoming <1/0>, but I think that's fine and both are still `==` to each other. [1] https://irclog.perlgeek.de/perl6-dev/2016-05-21#i_12521558 [2] 1f3ca6469759c79aa809d60a77 [3] 7a4ca4d90769ea03913f6a5eb8 [4] 498d0a4ae4572a84f80c0c5726
- Loading branch information
1 parent
4945dc4
commit 042cb74
Showing
2 changed files
with
37 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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