Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document Rational.base-repeating
  • Loading branch information
moritz committed Feb 14, 2015
1 parent d82788a commit 998065c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Type/Rational.pod
Expand Up @@ -45,4 +45,25 @@ Returns a list of the numerator and denominator.
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 detrmining the repeating group is limited to 1000
characters, above that, the second string is C<???>.
=end pod

0 comments on commit 998065c

Please sign in to comment.