Skip to content

Rats from calculations and from Rat.new have different limitsΒ #454

Open
@doomvox

Description

@doomvox

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    languageChanges to the Raku Programming Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions