-
Notifications
You must be signed in to change notification settings - Fork 16
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
Rats from calculations and from Rat.new have different limits #454
Comments
The denominator of a
I just peeked at Rakudo's The There's a comment above the Conclusion? It seems likely a good candidate for resolving this would be a PR that did
Based on my foregoing analysis I currently presume that both approaches can (and presumably should) have the same behavior, namely following the setting of the dynamic value of And further, I presume everything will all fall into place if the
Oh my! That sounded like an extraordinarily weak justification when I first read this issue, and I strongly doubted it was anything to do with something like that. Surely Raku(do) isn't that unprincipled! 😱 Anyhow, I then did research and drew the conclusions I've given above which suggest it was just waiting 7 years for us to get to it, which Stefan et al did (and spent about a year elapsed time getting right iirc). Raku: patient, principled, practical, pragmatic, persistent, perfectionist. As part of preparing this comment I checked rational literal behavior and was surprised at its (apparent lack of) interactions with
|
Yes, I should've said something like "At present, Rats created from calculations are normally limited to 1 / (2⁶⁴ - 1)" to make it clear I was referring to the default overflow behavior. But then, if you've set "$*RAT-OVERFLOW = FatRat", then you wouldn't expect to be creating a Rat... But as raiph points out, setting the overflow behavior doesn't always do what you'd expect. Sometimes it does, though... consider:
|
I like @raiph s post and it looks that I share @doomvox s concern about this:
This looks like a plain old bug to me - surely an Int/Int division should produce a FatRat when the denominator is >=2^^64. Looks like sometimes we check |
At present, Rats created from calculations are limited to 1 / (2⁶⁴ - 1),
and yet a Rat created via Rat.new can exceed that precision.
This oddity seems very peculiar, and I suggest that we consider
adding bounds checking to Rat.new so that both approaches have
an identical limit.
The current behavior is documented, but the rationale for it isn't: my
presumption is that it's intended to improve efficiency by avoiding
doing a check that will be redundant in many cases.
The difficulty here is that it makes the definition of a Rat a
little fuzzy, which makes it difficult to talk about it clearly:
this issue is addressed in a few places in the "language/numerics" page,
but it requires a code example to make the behavior clear:
https://docs.raku.org/language/numerics
If you don't see what I mean, try describing what a Rat is informally,
perhaps speaking out loud. "Though actually, you can have Rats fatter
than normal Rats but which are not FatRats..."
(Thanks to Rob Ramsbottom for calling this to our attention at the
SF Perl Raku Study Group.)
The text was updated successfully, but these errors were encountered: