News for hackers. Stuff that matters.
Re:In defense of 'flicks' (or how I learned to stop worrying... by 333c on Monday November 25, 2019 @07:32PM (#21634479)
> 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by zaroth on Monday November 25, 2019 @09:40PM (#21635200)
I 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!

Re:In defense of 'flicks' (or how I learned to stop worrying... by slimscsi on Monday November 25, 2019 @10:28PM (#21635431)
Thank you.
Re:In defense of 'flicks' (or how I learned to stop worrying... by 333c on Monday November 25, 2019 @10:08PM (#21635345)
I 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by scarejunba on Tuesday November 26, 2019 @03:55AM (#21636586)
Mate, 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by yaccz on Tuesday November 26, 2019 @03:42AM (#21636549)
The 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by slimscsi on Monday November 25, 2019 @07:42PM (#21634554)
Thanks 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by saagarjha on Monday November 25, 2019 @07:54PM (#21634665)
I 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by kragen on Monday November 25, 2019 @08:54PM (#21634994)
Agreed.
Re:In defense of 'flicks' (or how I learned to stop worrying... by 333c on Monday November 25, 2019 @08:03PM (#21634739)
I agree. This is a small change that makes the statement true.
Re:In defense of 'flicks' (or how I learned to stop worrying... by nanis on Monday November 25, 2019 @08:44PM (#21634946)
There 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by otabdeveloper4 on Tuesday November 26, 2019 @06:44AM (#21637438)
With 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by 333c on Monday November 25, 2019 @07:50PM (#21634629)
The 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/

Re:In defense of 'flicks' (or how I learned to stop worrying... by slimscsi on Monday November 25, 2019 @08:00PM (#21634719)
Thanks 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!
Re:In defense of 'flicks' (or how I learned to stop worrying... by retsibsi on Monday November 25, 2019 @10:15PM (#21635380)
I 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by jeswin on Monday November 25, 2019 @10:55PM (#21635537)
I enjoyed the article. Please ignore the nitpicking that goes on around here.
Re:In defense of 'flicks' (or how I learned to stop worrying... by swiley on Monday November 25, 2019 @10:14PM (#21635374)
You 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.
Re:In defense of 'flicks' (or how I learned to stop worrying... by phonebucket on Tuesday November 26, 2019 @05:44AM (#21637119)
Upvoted for the sentiment. Although using log(1) to represent e gives me nothing (pun intended).
Re:In defense of 'flicks' (or how I learned to stop worrying... by jwilk on Tuesday November 26, 2019 @06:16AM (#21637295)
log(1) = 0

I think you meant exp(1).

Re:In defense of 'flicks' (or how I learned to stop worrying... by swiley on Tuesday November 26, 2019 @09:27AM (#21638507)
Darn, as much as I hate editing posts that old I do wish I could correct that.
Re:In defense of 'flicks' (or how I learned to stop worrying... by 3JPLW on Monday November 25, 2019 @10:18PM (#21635395)
Cripes, 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by SeanDav on Tuesday November 26, 2019 @04:33AM (#21636770)
> 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.

Re:In defense of 'flicks' (or how I learned to stop worrying... by echlebek on Tuesday November 26, 2019 @12:38AM (#21635875)
A floating point number with an infinitely sized mantissa could represent it exactly, which would require infinite memory.