2

We got another “my floating point values don’t compare as equal” question again today.

When we get a “Null reference exception” question I often point them to John Saunders’ excellent canonical answer. Can we consolidate some of the existing floating-point precision answers into a canonical answer?

1

Can we consolidate some of the existing floating-point precision answers into a canonical answer?

Yes, we should. And yes, you can.

There is no point in asking a brand new question for this, you can just use one of the many existing dupes that you mention. In fact, the very question you linked would be as good as any to start with.

Edit it a bit to generalize the question, and then post a comprehensive, canonical answer that both explains the cause of the behavior and gives some ideas on how to "fix"/work around it. You can also include links to off-site resources, as long as the information they contain is appropriately summarized in your answer.

If you feel that you are sufficiently knowledgeable about to the topic to post a high quality answer of your own, then go ahead and do so. Leave it in your full ownership, and reap the reputation rewards from it.

If not, you can go ahead and start answering the question, using the information you do know and the information you find in the tag wiki that Robert linked you to, as well as elsewhere on the web. Do mark the answer as "community wiki" so that it can be collaboratively edited and improved by other members of the community. You won't get the reputation rewards from it directly, but that's fair since you won't be the primary author. You will still benefit, as will all of us, from having this information available online and having a good dupe-closure target.

For some ideas on how to build canonical questions and answers, you might look at these examples:

  • Questions with the tag that the C++ community has been building
  • Some of the PHP canonical/FAQ questions that Gordon mentions here
  • John Saunders's NullReferenceException question and answer (to which you already linked)
    (Note that I personally think it would have been better if John had simply re-used an existing question on this topic to post his answer, rather than asking a new one. The way he did it is acceptable, but not the best way as far as I'm concerned, considering the impetus was the sheer quantity of questions we get on the same topic—plenty of existing questions to choose from.)
  • The question you linked is not good enough to be the canonical, and it doesn't look like there's enough there to edit it into shape. – Robert Harvey Aug 17 '13 at 5:37
  • I don't really see why. What more should it say? It looks like a perfectly acceptable question to me. – Cody Gray Aug 17 '13 at 5:40
  • 4
    How to discard the garbage values of a double. Really? Who is ever going to Google that? I think we should start with a brand new question and do it right, rather than co-opting someone else's. Unless, of course, you can find a better one to serve as the canonical. – Robert Harvey Aug 17 '13 at 5:40
  • The big problem with this question family is that anyone who sees their question as part of the family already knows the answer. The people who ask the questions assume their issue is specific to what they are doing, and search based on that assumption. – Patricia Shanahan Nov 13 '13 at 14:44

You must log in to answer this question.

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