5

Quite a while ago I asked a question "If any object of the java abstract class “Number” is equal to zero"

There was multiple answers, mostly advising to do number.doubleValue() == 0, However each time someone gave this answer, they were immediately downvoted. They would then delete their answer (I assume to avoid further downvotes), then the next person would come in and give this same answer. One person waited long enough for people to have a conversation in the comments and say why it was a bad answer. By the time they resolved why, they had around a -5, then deleted their answer.

I wanted to post a community wiki answer one why you shouldn't use that method, but I could no longer see the answer/comments of that deleted answer. I found out that the privilege to view deleted posts required 10,000 reputation. Can I request to see a deleted answer and the associated comments, or is the right answer to wait until I have enough reputation?

10
  • 2
    The best general solution is to visit Stack Overflow Chat. You will usually find a 10K user who will help you retrieve a specific answer from a question. Commented Feb 9, 2016 at 1:28
  • You can, but why would you want to tell people how not to do it? Why not just leave it at how it should be done?
    – user4639281
    Commented Feb 9, 2016 at 1:30
  • 1
    @TinyGiant because sometimes novices need to know why not to do something stupid. Commented Feb 9, 2016 at 1:31
  • Or you could just tell them the right way, avoiding the possibility that they don't read the "don't do it this way" part of the answer and use the bad code. @psubsee2003
    – user4639281
    Commented Feb 9, 2016 at 1:32
  • @TinyGiant Considering that several people tried to give similar bad advice it seems to hold that a "Don't do X because of Y" may be in order.
    – apaul
    Commented Feb 9, 2016 at 1:39
  • ... or downvotes and delete votes of subsequent bad answers are in order. @apaul34208
    – user4639281
    Commented Feb 9, 2016 at 1:41
  • Here you go: i.sstatic.net/YE0Qc.png Commented Feb 9, 2016 at 1:46
  • @TinyGiant Ya... crap should be deleted, particularly redundant crap, but saving people a few hours/headaches by explaining why their clever idea isn't so clever seems like the right thing to do. Making the internet a better place n' all, right?
    – apaul
    Commented Feb 9, 2016 at 2:02
  • I really can't get behind the idea that telling users how not to accomplish a task is making the internet a better place. If a user tries something the wrong way, and it doesn't work, they'll post a question about it, where someone will educate them about why they can't / shouldn't do it that way. @apaul34208
    – user4639281
    Commented Feb 9, 2016 at 2:04
  • @TinyGiant I guess my question was focus too much on my experience. I was trying to provide an example of a valid motive to request to seeing something I do not yet have the Privilege of seeing. I think psubsee2003's comment on the chat is fantastic, and I didn't know the chat even existed. Whether or not making a community wiki about what not to do and why, may be another (meta)question entirely I guess.
    – jgawrych
    Commented Feb 9, 2016 at 2:17

1 Answer 1

3

I think you mean this answer, which had 3 downvotes and 1 upvote.

The main comments were

Won't work if the Number is capable of holding a value with finer precision than a double (for example, an arbitrary-precision number library). – nneonneo Aug 11 '14 at 21:18

What if it's BigDecimal? – PM 77-1 Aug 11 '14 at 21:20

And in the case of BigDecimal? Or MyNumber? This is also wrong, but will cause much more insidious bugs than the (now deleted) intValue() suggestion. – Boris the Spider Aug 11 '14 at 21:21

additionally, comparing Double or Float for equality never works as expected - in fact, i doubt it even works AT ALL (someone correct me if im wrong) - without a sensible delta, equals or == makes no sense with floating-point types. – specializt Aug 11 '14 at 21:22

It should be obvious that "best bet" is not good enough. If the question was "how can I check whether a Number is zero some of the time" then this would certainly be an answer. But so would .equals(0). – Boris the Spider Aug 11 '14 at 21:22

"i hid the problem since it doesnt affect my right now, therefore it doesnt exist". I think your "best bet" isnt enough. At least throw RuntimeException if your method doesnt receive pre-set instances of Number, that will at least avoid the BIGGEST mistakes. – specializt Aug 11 '14 at 21:24

Almost all dealings requiring accurate representations of decimal quantities use BigDecimal - money for example should be represented as a BigDecimal. – Boris the Spider Aug 11 '14 at 21:26

I didn't include comments from the author because, since he deleted the answer, he might not want it to be associated with him.

1
  • Huh, only 3 downvotes and 1 upvote? My poor memory of -5 must have been exaggerated. Thank you!
    – jgawrych
    Commented Feb 9, 2016 at 2:20

You must log in to answer this question.

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