3 ms·
Ah, I should have looked at more of the responses. This amusingly blew up on me well after I stopped watching. :D I don't tend to give much thought to real ve
by taeric 1y ago
Ah, I should have looked at more of the responses. This amusingly blew up on me well after I stopped watching. :D
I don't tend to give much thought to real versus rational. Such that I still find it not that surprising to see people treat floats as reals. Especially since most languages make it hard to represent anything else. To that end, it will take me a bit to really internalize what you are saying here. I think I understand it.
That said, my favorite for the craziness of "old is new" is that the literal "1/3" works to represent a rational in Common Lisp. Indeed, I had originally thought that they had some specific constants for common fractions defined. Nope, they just support rational literals.
And I question if you need infinite space to represent repeated decimals. Strictly, you just need a way to indicate the repeating. No?
- kazinator 1y agoRepeating decimal fractions are just rationals with 9s in the denominator: .123123123... = 123/999. Fourth grade long division.
- taeric 1y agoI'm not sure what you mean? 1/7 repeats, as well. As does 1/14. As do... a lot of fractions. https://projecteuler.net/problem=26 https://projecteuler.net/problem=26 was a fun problem to explore for some that I remember. Pretty sure there were other problems on this general theme, as well. My point was strictly that we have "bar notation" in writing to show that 1.3 is not the same as 1.33 or 1.333 or 4/3. No matter how many 3s you put at the end. I don't know of any similar scheme in computers. I'm assuming it has been tried.
- kazinator 1y ago1/7 is 142857/999999 from which representation you can readily infer that it is 0.142857 with a bar over it. The 9s are verbose but mean the same thing as a bar over as many fractional digits.
- taeric 1y agoAh, I see your point, I think. You are just pointing out that any repeating decimal is a ratio. Which, fair, but my question was if a bar representation was ever tried. The idea being that you don't need to have infinite storage to represent a ratio in positional digits any more than you have to use infinite paper to write a ratio's value out. That is, yes, I know that 1/6 can be used to represent 0.1(6), but if you are already storing something in positional digits, there may have been a benefit to keeping it in positional digits? I'm assuming there was not, in fact, any benefit?
- kazinator 1y agoI don't know of a bar representation in a programming or data language. It requires either digit characters that have a bar, or the effect somehow produced via combining characters. Or else a multiline syntax where the coder has to prepare underscores over the digits in the previous line, and this is checked for alignment by the parser. (We could think of other representations like 0.12'34 or something where the '34 indicates repeating digits. I've not seen that anywhere either, but it would be easy to implement.)
- taeric 1y agoI was assuming a BCD scheme to do something like this, at the binary level. At the text level, I'd assume parens to indicate the group would be common. Is what that Euler problem did, though; so I'm probably just biased on that. Actually getting the overbar, I wasn't too concerned with. Just noting that we have a way to do it on paper that doesn't require using ratios directly. Or infinite paper. :D At any rate, this also got me thinking about how to do operations on repeated digits. I'm assuming I would have learned something like this years ago, but I don't remember it. At all. I vaguely remember it was awkward to realize that 0.(9) == 1. But, I don't recall playing with that too much. Is neat to see you should be able to make the general ideas work out just fine after you account for that? Just widen any repeating groups so that they are the same size, and then add. Reduce using the 9 rule.
- perching_aix 1y ago> Strictly, you just need a way to indicate the repeating. No? It depends on your data structure, yes. You can also do the separate numerator / denominator thing, and I'm sure there are other ways too. Just that naively if you try representing it, that's when you need infinite space. Or if you do it the way IEEE-754 formats do.
- taeric 1y agoApologies, almost missed this response. Agreed that there are other ways, almost certainly. I was going with the assumption that we wanted to store positional values for that question. That is, it is only when you assume that you have to write out all decimal digits that you get people writing silly things that computers do all of the time. "0.66666...7" is an easy example. Ironically, to me, is that in written assignments you likely would have gotten knocked off points for not writing 0.(6) where () means an overbar. You definitely would lose points for rounding at the end.