On Fri, 21 Feb 2020 at 13:31, ToddAndMargo via perl6-users
<perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
$ perl6 -e 'say sqrt(2).base-repeating();'
No such method 'base-repeating' for invocant of type 'Num'
in block <unit> at -e line 1
On 2020-02-20 19:07, Norman Gaywood wrote:
perl6 -e 'say sqrt(2).Rat.base-repeating();'
(1.4
14213197969543147208121827411167512690355329949238578680203045685279187817258883248730964467005076)
Hi Norman,
Much better!
Question: Rat:
https://docs.raku.org/type/Rat
Rat objects store rational numbers as a pair
of a numerator and denominator. Number literals
with a dot but without exponent produce Rats.
What does Rat do to sqrt(2) to give it a numerator
and a denominator?
And I see base-repeating wants to be fed a Rational:
https://docs.raku.org/routine/base-repeating
Also I much prefer:
$ perl6 -e 'say <1/7>.base-repeating();'
(0. 142857)
over
$ perl6 -e 'say (1/7).base-repeating();'
(0. 142857)
As to me (1/7) means solve the equation and then
send it on.
Also, what is base-repeating telling me? Where the
repeat is? What the repeat is?
And what if I only want to see if a repeat occurs
in a single number, not a Rat/Rational?
$ perl6 -e 'say <0.9876123412341234/1>.base-repeating();'
(0.9876123412341234 )
I am doing something wrong.
Many thanks,
-T