method base-repeating

Documentation for method base-repeating assembled from the following types:

role Rational

From Rational

(Rational) method base-repeating

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

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

my ($non-rep$repeating= (19/3).base-repeating(10);
say $non-rep;                               # OUTPUT: «6.␤» 
say $repeating;                             # OUTPUT: «3␤» 
printf '%s(%s)'$non-rep$repeating;      # OUTPUT: «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;          # OUTPUT: «("2.5", "")␤»

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

$base defaults to 10.