6 ms·
> The number result is 0.008333333333 with the 3 repeating forever. For a computer to store a number that repeats forever would require an infinite amount of me
by 333c 7y ago
> The number result is 0.008333333333 with the 3 repeating forever. For a computer to store a number that repeats forever would require an infinite amount of memory
This is very much not true, as I'm sure other HN readers will notice. The number is rational (it's equivalent to 1/120). Now, it is true that a floating point number may not be able to represent it exactly, but by no means does this number require "infinite memory." In fact I have represented the number exactly in this comment, which does not take up infinite space.
For irrational numbers, sure, they cannot be exactly represented. But there are no irrationals involved in this article.
I got hung up at this point in the article, so I haven't finished it yet, but it looks like the author goes on to argue that because numbers like the above cannot be represented in computer memory at all, errors will always accumulate in representations of audio/video. This makes me question whether the author understands the problem they are writing about.
Edit: the author does in fact state that rational numbers can be represented by a numerator and a denominator. The article is actually about errors the accumulate during floating point operations. It ends up making a decent argument despite false claims about representing numbers in memory.
- slimscsi 7y agoThanks for the comment. For the record, I am very aware of iee 754, And I am aware that some numbers that have infinite repetition in decimal can have an exact representation. I actually thought about pointing that out. However I decided that it didn't add much to the post. It was written for more of a general audience and diving into those details, while would make the post more technically correct, would not actually add any value for the average reader.
- 333c 7y agoThe issues of "repeating decimal" and exact representation as a floating point number are orthogonal. Because the mantissa in a floating point number (which is fixed width) is in base 2, only fractions with denominators that are powers of two can be exactly represented. This means that simple base-10 decimals like 0.1 cannot be exactly represented by a float. For this reason it's at least a bit misleading to talk about how some numbers cannot be represented with finite memory, and then go straight into a demonstration of how they can in fact be represented in finite memory (as a fraction). As for the comment about a general audience, if (some of) your target audience is HN readers, I think it's reasonable to expect many readers to be familiar with computer science. If this were my article, I would replace the paragraph in question with a discussion of the error introduced in floating point calculation — consider perhaps that many programming languages will tell you 0.1 + 0.2 = 0.30000000000000004 [0]. [0]: https://0.30000000000000004.com/ https://0.30000000000000004.com/
- slimscsi 7y agoThanks again for the refresher. But again I am keenly aware for how floating point works. As for audience, this is not a hacker new exclusive. It just happens to be here rite now. It will probably make rounds in other forums as well. If you want to write an post an article on how floating point works. I’ll be happy to read it!
- retsibsi 7y agoI know this sort of criticism can be annoying, but despite commenting on HN I would surely qualify as a 'lay reader' in this context, and I have a strong preference for authors taking care to either tell the whole truth or flag that a potentially misleading simplification has been made -- even if the falseness seems like a technicality to the author. If I notice it then I lose faith in the author's credibility, and if I don't then now I've 'learned' something false.
- ZenPsycho 7y agoYou sound like someone who doesn't know how to critically determine whether something is true independently of reading it in an article, or detect whether someone has likely made a simplification for the benefit of a non technical audience from the tone an article is written in. I wonder what you do if you read two articles that each make conflicting claims. How do you decide which is telling the truth?
- jeswin 7y agoI enjoyed the article. Please ignore the nitpicking that goes on around here.
- saagarjha 7y agoI don't want to come off as combative, but I would argue that a correction would add quite a bit to the post. What you have is straight-up incorrect and wouldn't even take that much effort to fix. "For a computer to store the decimal representation a number that repeats forever would require an infinite amount of memory, so the number is approximated" would be correct and it's just a couple words more.
- nanis 7y agoThere are uncountably infinite real numbers and countably infinite rational numbers, so we cannot represent all of them using a {0, 1}^n where n is a finite number. No matter which numbers you can exactly represent, there will always be uncountably many real numbers which are not exactly representable, and, conversely, the set of real numbers exactly representable using a finite number of bits will have measure zero.
- deleted 7y ago[deleted]
- otabdeveloper4 7y agoWith all due respect, you sound like you don't understand the difference between rational and real numbers. Also, the 'decimal' part of your comment is not needed, number base is irrelevant here.
- pg_is_a_butt 7y agoI got hung up on this too... so entirely wrong, I can't even bother wasting my time continuing reading. For a contradictory example, even with an infinite amount of memory, a computer cannot store the floating point number .1
- deleted 7y ago[deleted]
- zaroth 7y agoI wish you had kept reading. In the end, you nitpicked about precisely the thing which the author ended up explaining. The point about using infinite memory to store an irrational number is just a rhetorical device / presentation style to keep the novice reader engaged, and following along. And then you say, "Next we will explain how to solve this impossibility...," and such. It's a good technique for writing, and presenting, but doesn't work if your audience already knows where you're going and gets impatient with you!
- 333c 7y agoI did keep reading the article, as I say in my edit. I differ from you in my interpretation of this facet of the essay. To me, it reads as internal contradiction — the author says that it is impossible to represent 1/120 in memory and then goes on to describe a strategy for doing just that. The author does not present this conflict as "it may seem impossible…" but rather as "is is impossible." That's an inaccuracy, not a writing technique.
- yaccz 7y agoThe claim is only missing a qualification that the impossibility exists within the framework of ieee 754. It can be easily inferred from context and it is important to note because thats what the major CPU architectures use to store native floating point numbers. Therefore, the point is, we need a non-native (wrt the cpu) way to store and calculate with irrationals and some rationals if mathematical precision is required.
- scarejunba 7y agoMate, I mean this with the best of intentions: please reflect on your requirement for exactness and consider whether it serves you well. I did so with mine and I concluded it did not. Perhaps you will conclude differently. Perhaps the same. In either case, I think you will find it worthwhile.
- slimscsi 7y agoThank you.
- swiley 7y agoYou can represent most useful irrational numbers on computers via programs that calculate them to the required degree of precision: You can represent pi: 4*atan(1) e: log(1) Now I feel like you could make arguments about non-computable numbers, although I feel like you could still “represent” them.
- phonebucket 7y agoUpvoted for the sentiment. Although using log(1) to represent e gives me nothing (pun intended).
- jwilk 7y agolog(1) = 0 I think you meant exp(1).
- swiley 7y agoDarn, as much as I hate editing posts that old I do wish I could correct that.
- 3JPLW 7y agoCripes, you're clearly smart enough to understand that the author meant "to [literally] store [all the digits/bits of] a number that repeats forever [in the given base] would require an infinite amount of memory." Talk about splitting hairs.
- echlebek 7y agoA floating point number with an infinitely sized mantissa could represent it exactly, which would require infinite memory.
- SeanDav 7y ago> The number result is 0.008333333333 with the 3 repeating forever. For a computer to store a number that repeats forever would require an infinite amount of memory This is clearly a literary technique to create interest. Like saying something like "I told you a billion times not to exaggerate". It should be clear to most readers that this is not an attempted mathematically precise comment.