=begin pod

=TITLE role Rational

=SUBTITLE Number stored as numerator and denominator

    role Rational[::NuT, ::DenomT] does Real { ... }

C<Rational> is the common role for numbers that are stored as pairs of
numerator and denominator. It is parameterized by the types of the numerator
and denominator.

Built into Perl 6 are L<Rat> and L<FatRat>, which both do the C<Rational> role.

=head1 methods

=head2 method new

    method new(NuT:D $numerator, DenomT:D $denominator) returns Rational:D

Creates a new rational object from numerator and denominator.

=head2 method numerator

    method numerator(Rational:D:) returns NuT:D

Returns the numerator.

=head2 method denominator

    method denominator(Rational:D:) returns DenomT:D

Returns the denominator.

=head2 method nude

    method nude(Rational:D:) returns Positional

Returns a list of the numerator and denominator.

=head2 method norm

    method norm(Rational:D:) returns Rational:D

Returns a normalized Rational object, i.e. with positive denominator, and
numerator and denominator coprime.

=head2 method base-repeating

    method base-repeating(Rational:D: Int:D() $base)

Returns a list of two strings that, when concatenated, represent the number in
base C<$base>. The second element is the one that repeats. For example:

    my ($non-rep, $repeating) = (19/3).base-repeating(10);
    say $non-rep;                               # 6.
    say $rep;                                   # 3
    printf '%s(%s)', $non-rep, $repeating;      # 6.(3)

19/3 is 6.333333... with the 3 repeating indefinitely.

If no repetition occurs, the second string is empty:

    say (5/2).base-repeating(10).perl;          # ("2.5", "")

The precision for determining the repeating group is limited to 1000
characters, above that, the second string is C<???>.

=end pod
