On Wed, 26 Feb 2020, ToddAndMargo via perl6-users wrote: > > > $ p6 'say (99/70).base-repeating();' > > > (1.4 142857) > > > > > > means that 142857 also repeats (it does not), but > > > that it is best it can figure out with the precision > > > it has? > > > > > > > What are you talking about? It does repeat. I suggest you take a piece > > of paper and compute the decimal digits of 99/70 by hand until you are > > convinced that it is 1.4 and then an endless stream of 142857 repeating. > > I used gnome calculator to 20 digits: > 665857/470832 > 1.41421356237468991063 > Sorry. Not seeing any repeating patterns. >
Todd, you were asking about 99/70, so I answered you about 99/70. I even quoted it. Now you come with 665857/470832. For that number, you will see the repetition after about 580 decimal digits. > Here is NAS doing it to 1 million digits (they have too > much time on their hands): > https://apod.nasa.gov/htmltest/gifcity/sqrt2.1mil > No repeats. > > So why does base-repeating tell me there is a repeating > pattern when there is not? > Sigh. We already settled that Rat and Num in Raku are rational numbers and that √2 is an irrational number. So what can you definitely not apply the base-repeating method to in Raku? -- The honest value of √2. NASA apparently computed the first million digits of √2 and you see no repeated digits. Good. In fact a real number is irrational if and only if its decimal expansion has no repeating pattern. You can view this as a reason for why they are not super easy to deal with on a computer. But that has nothing to do with the numbers we looked at above. Those were obviously rational numbers. They were obviously different from √2 because that number is not rational -- and we were looking at rational numbers. We were looking at rational numbers close to √2. What makes you think that NASA computing digits of the number √2 has any bearing on the correctness of `(99/70).base-repeating`? Because √2 and 99/70 are obviously not the same number. We are not working out the decimal expansion of √2. We are working out decimal expansions of rational numbers close to, but different from, √2. Even though they are close, structural properties of the expansions, like the existence of a repeating pattern, are radically different. > Ah ha, 99/70 does have a repeat: > 1.4142857 142857 142857 1 > > Maybe 665857/470832 I just do not go out enough digits to > see a repeat. > > √2 does not repeat though, but I am thinking that > I am stretching the poor machines abilities a bit too far > and that is where the repeat comes from > > $ p6 'say sqrt(2).Rat.base-repeating();' > >> (1.4 > >> 14213197969543147208121827411167512690355329949238578680203045685279187817258883248730964467005076) > > So, with the technology on hand, the approximation of √2 > does have a repeating pattern of > > 14213197969543147208121827411167512690355329949238578680203045685279187817258883248730964467005076 > > (And in engineering terms, is meaningless) > Yes, √2 has no repeating decimal pattern and the repetition returned to you is the one of the rational approximation to √2 that Raku computed when you asked for `sqrt(2).Rat`. (Somehow it seems like you understood halfway through writing your response but decided to keep the first half anyway. I don't know why.) > > > And what are the unboxing rules for (665857/470832)? > > > > > > > No idea what you mean. > > When is <665857/470832> unboxed to a Real number to > operate on it? Or is it never unboxed? > I'm no boxing expert, but I know that Rat has high-level arithmetic defined for it and there is no native rational type to unbox to. That would have to go through Num, I suppose. So I see neither a need nor a target for unboxing a Rat. But I still have no idea what kind of operations you have in mind. That said, Rat is not a NativeCall- related type. -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk