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: Int() = 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 (, ) = (19/3).base-repeating(10);say ; # OUTPUT: «6.»say ; # OUTPUT: «3»printf '%s(%s)', , ; # 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
.