6

I recently saw a question closed as a duplicate that in my mind goes under the category "Same answer but not the same question". It's the most common question around, loss of precision in floating point operations.

ugly doubles - why 2.9000000000000004 instead of 2.9?

was closed as a duplicate of

Is floating point math broken?

First of all, I think it should be reopened just because he is asking about how to avoid it and not wondering whether something is wrong.

But in the larger picture, aren't the questions different because they arise from very different situations (language in this case)? This question could ofcourse be answered without a mention of any specific language.

  • 1
    The JavaScript question could be edited to make it more language neutral. It appears to be the focal point of many duplicates. – Duncan Jones Jul 22 '13 at 13:20
3

Even as a card carrying member of the close-all-questions society, I don't think this is a valid closure. The questions are clearly about two different languages. The fact that the two languages share the same floating point behavior (indeed, all important computer microarchitectures share the same floating point behavior) is merely incidental.

Null reference/pointer exceptions are the same in nearly all languages, too, but it would be inappropriate to close a C# question about it with a similar C++ or Java question, even if the answers would say close to the same thing. Except perhaps on Meta, we don't close questions as duplicates because they have the same answer as another question, but because they are asking the same question.

If you wanted to close all of the floating point questions as duplicates of something, the way to do it would be to create a general, language-agnostic question about surprising floating point behavior, and then post a detailed, canonical answer. The C++ folks have been doing this with commonly-asked C++ questions, tagging them , and I think it's been fairly successful. It's not been without its share of controversy, of course, but that's par for the C++ course, and you can't please everyone. I think that, assuming these canonical questions have excellently-prepared, thorough, and high-quality answers, they are not only a great resource but perfectly legitimate duplicate-closure targets.

Along the earlier-mentioned lines of null reference/pointer exceptions, John Saunders and some other folks got tired of NullReferenceException questions popping up all over the place in the C# and .NET tags. So they did what I just described: created a canonical question with detailed answers explaining the problem and how to go about fixing it. This works particularly well here because the real solution is to use a debugger. There's not usually any way to be more specific, regardless of the details in the question.

Presumably that's what people are trying to do with that JavaScript question. It's been around for a while, picked up quite a few votes, and unfortunately a dizzying array of answers. The problem is that the question, as it stands now, is still JavaScript-specific. So are some of the answers (though not all). That means it's not a good general canonical question. You could perhaps edit and generalize it, but it may be a better idea to start a new question rather than co-opting Cato's.

And aside from all of that, you do have to take care to read the original question that is actually being asked before voting to close as an obvious duplicate. If the asker is not merely seeking an explanation of why the behavior is occurring, but wants to know how to fix it under a particular set of circumstances and for some particular needs, then this is a significantly different question and should not be closed as a duplicate of some general question about floating point weirdness.

  • +1 "Except perhaps on Meta, we don't close questions as duplicates because they have the same answer as another question, but because they are asking the same question." > Good to know, that had been bothering me for a while. – Duncan Jones Jul 22 '13 at 13:30

You must log in to answer this question.

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