base-repeating
ErrorsCollection

base-repeating

Synthesised documentation from type/Rational

From type/Rational

See Original text in context

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).raku;          # 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.