Hacker News new | ask | show | jobs
by 333c 2398 days ago
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/

1 comments

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!
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.
I enjoyed the article. Please ignore the nitpicking that goes on around here.