11

There was an established canonical that deals with floating point arithmetic with the catchy title "Is floating point math broken?".

The "was" used because now the title is "Why does floating-point arithmetic not give exact results when adding decimal fractions?"

See the revisions of the post. #21 changes to the new title #22 rolls back to the old one, #23 rolls back the rollback. It is a mini edit war.

The reason given for the change is "less clickbaity title" and I do get the sentiment. The title, while catchy is not very descriptive about what exactly is broken. As a summary - some mathematical operation on fractions will result in surprising results. The most well known is this innocent looking mathematical expression.

console.log(0.1 + 0.2); //0.30000000000000004

It is so well known there is a website dedicated to this problem with floating point arithmetic: https://0.30000000000000004.com/

At any rate, the problem with the new title is that while it narrows down the "brokenness" it narrows it down too much. The problem is not only with addition. The very reason I noticed the new title is because I opened a question which asked why the following expression is false: (18392.19 * 10 * 10) === (18392.19 * 100) which is down to the exact same issue with floating point arithmetic. Yet it is not about addition.

console.log(18392.19 * 10 * 10); // 1839219
console.log(18392.19 * 100);     // 1839218.9999999998

It was surprising to me that it was linked to a duplicate about addition. As I knew it by the old name.

I do not have a particular preference for the old title. However, this is not even the first time the title was altered - in revision #17 it was changed to "Why do inaccuracies occur in floating point math operations?" and I suspect that every once in a while somebody would come up to try and revise it to something they believe is useful. This is an early intervention: I would prefer if there was a wider discussion and some consensus what the title should be.


The edit was rolled back again while writing this. It is back to "Is floating point math broken?". Henry Ecker changed it saying:

I rolled it back. The proposed title was overly restrictive as it does indeed apply to all math operations. I'm not opposed to a title change to be "less clickbaity" but not that specific one.

10
  • 8
    "Why does floating-point math give me the wrong answer?" - Gets rid of the operator specifics, and is a bit more specific than just "broken" or "doesn't work"
    – aynber
    Mar 2 at 19:36
  • 2
    Am I the only one who’s constantly bothered by the misuse of singular in the word “math”? It’s “mathematics”, folks! If we’re going to fix the title, let’s fix that first and foremost for all the poor British borderline OCD sufferers like myself
    – Clive
    Mar 2 at 19:39
  • 8
    Rather than "wrong answer" I would suggest "unexpected results". The answer isn't "wrong" when you understand how the values are stored.
    – Thom A
    Mar 2 at 19:39
  • 3
    I also like the word "inaccurate", like "Why are my floating point numbers/values inaccurate?". But I also prefer the old title more than the "new" one.
    – Tom
    Mar 2 at 19:44
  • Talking about some (broken) Title, I find the current Title for this Thread ("Please float some less broken canonical titles for this post") pretty cryptic and not really-really self-explanatory, => kind of broken also for me, I would think, just saying...!
    – chivracq
    Mar 2 at 21:07
  • 1
    @Larnu While the implementation may dictate that 0.1 + 0.2 != 0.3, I think it's very much correct and accurate to describe that behavior as "wrong" from a conventional perspective. The reason that expression is false amounts to a computer quirk, not because it's "right" or "correct" in a meaningful way.
    – zcoop98
    Mar 2 at 21:08
  • 1
  • 3
    What is wrong with clickbaity titles? A 'Future Unity' (YouTube) one would be "Facts about floating point math that terrifies the entire industry" Mar 3 at 22:30
  • The change to the title was not good anyhow, because the issue is not one-to-one tied to "adding decimal fractions", because (1) there can be other operations than "adding" that lead to the behaviour, and (2) not all decimal fractions translate to periodic binary digits.
    – trincot
    Mar 4 at 12:16
  • 2
    Does "clickbait" actually happen on stackoverflow? This is not YouTube, people don't click a post just because the title is attractive.
    – Ricky Mo
    Mar 6 at 1:51

4 Answers 4

32

The original title is fine; I see no real reason to adjust or tweak it.

Notwithstanding its pithiness (and yes, click-baitiness), there was an attempt to change the title which was rolled back. This sends the signal that the community is largely comfortable with the title as-is.

It also preserves the original spirit and impetus of the question. Someone legitimately wondered if it was floating-point math that was broken. Why lose that?

5
  • 3
    "Someone legitimately wondered if it was floating-point math that was broken. Why lose that?" Because it isn't a matter of OP having misidentified the problem, but of having characterized it in an unhelpful way. Preserving OP's linguistic flair shouldn't be important because this is not a discussion forum. What matters is clarity. Mar 3 at 16:48
  • 4
    @KarlKnechtel: I don't see how it's unclear here. OP added 0.1 and 0.2 and for their entire life they had been taught that it was exactly equal to 0.3. Armed with their knowledge in classical math, it is clearly the computer which is producing the wrong result. This is the crux of the problem in my eyes; floating point math appears broken if you don't know your IEEE 754.
    – Makoto
    Mar 3 at 16:50
  • 3
    @KarlKnechtel: I had remarked to you a while back that people don't often know the right way to express their problem. This is one of those cases that has proven to be wildly successful and incredibly easy to find when someone runs into this issue. I see no value in being overly dogmatic in trying to wordsmith the title into something "better".
    – Makoto
    Mar 3 at 16:52
  • FWIW, apparently it was not controversial to edit OP's original title, and the tags, to make the question language-agnostic. It was also not controversial to edit that title to mention floating-point where it didn't before. Of course, this is before it had so many views. Mar 3 at 16:53
  • 4
    @KarlKnechtel: No, because this happens in more languages than JavaScript. So it makes sense to introduce this as language-agnostic. (You also avoid the rule lawyers whinging about their question closed because "I'm working in C and this is an answer in JavaScript so clearly it's different".)
    – Makoto
    Mar 3 at 16:54
26

Although the proposed new title ("Why does floating-point arithmetic not give exact results when adding decimal fractions?") might better match the narrow context of the question's actual examples, that doesn't really matter. The question's original context (I believe it was originally JavaScript-specific, but is now explicitly language-agnostic) is long gone, and it's now used — more or less daily — as the canonical dupe for all manner of questions (about far more than just adding decimal fractions) which all boil down to "wait a minute, I'm getting bizarre results from floating point, is something broken here?". Everybody knows this question by its traditional title, clickbaity or otherwise. That title is so well known that it really has to stay.

1
  • 1
    That's a good point actually, I would not consider that myself. Don't change the title that everyone knows by heart.
    – Gimby
    Mar 3 at 9:18
17

I think the original title is perfectly fine and so far it does not look like it caused serious problem understanding or finding the question. Just leave it alone.

If you really want to have another title - create another post (unique from 4K+ existing linked questions ) and mark it as duplicate so more specific title also indexed by search engines.

0
1

When we talk about titles being "click-baity", I understand this to mean that people who see the title will feel a compulsion to read the Q&A, even if it is not relevant to their problem. This is only harmful to the site if there is a significant probability of the Q not being relevant.

I see a different problem with the title: it is not adequately descriptive of the problem. "Broken" is about as informative as "doesn't work". The issue (in normal cases; a few algorithms suffer catastrophic failure due to numeric instability, and in these cases it is usually worth having additional discussion of why the algorithm is unstable) is that the results are imprecise - i.e., almost right. This is qualitatively and importantly distinct from results that are any of:

  • unrelated to the input;
  • clearly and systematically wrong (e.g. always half what they should be);
  • not results at all (e.g. an error occurs instead).

Any of these four things could be called "broken".

Further, the problem is as much aesthetic as it is practical. While it's easy enough to discern that 0.30000000000000004 means a number that is very close to 0.3, inexperienced programmers will have a much harder time understanding that -5.551115123125783e-17 (the result I get in Python from 0.3 - (3 * 0.1) - which incidentally is twice the result from 0.3 - 0.1 - 0.1 - 0.1) means a number that is very close to zero.

I'm generally resistant to the logic of "question titles shouldn't be changed on popular canonicals because everyone knows that title". I'm always a little surprised to see other programmers being so, well, conservative when it comes to topics like that - improvement necessitates change. In my view, the most popular parts of the site are also the most important, and it is therefore important to elevate their quality as much as possible (i.e., above and beyond simply meeting site standards not to get a question closed).

People who commonly use a canonical for closing questions should be able to find it easily, yes. There are other techniques for that besides memorizing an exact title. Like remembering part of it, or putting it in one's saves, or fixing the site search, dear staff, please demonstrate at least the tiniest amount of care for the poor curators who do endless work for you for free.

My proposal: Why do I get imprecise or wrong-looking results from floating-point math?

I have consciously retained the core phrase from the original title - which gives people an appropriate breadcrumb - while hopefully also making it easier for people to find the Q&A without posting their own duplicate.

1
  • 5
    I expect that everyone with a dupehammer has used that question numerous times as a dupe target. Yes, the title isn't perfect, and it's a bit click-baity, but IMHO changing it now is counter-productive. If I was searching for it and it turned up under a different title I'd be a bit confused, and I'd have to waste time verifying that it was the question I was searching for. And if it didn't turn up as one of the top results in a search for its well-known title I'd be rather annoyed...
    – PM 2Ring
    Mar 4 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .