2

This is a simple question on difference. I have seen the following situation - for example how many day you spend on a travel when the travel date was 14-Aug-2014 till 25-August-2014. The answer for this is 25-14+1, which is 12 days. However, if I would have just subtracted, then the answer would have been 11, which is wrong. Now, the question, when I should do the difference + 1, and when I should just subtract. What is the idea behind it? How to identify when to apply what? The date part I know is just by experience, but I am worried I might fail in a similar situation where the application is different. Can someone please explain me this in detail?

dexterous
  • 621
  • 2
    I think you might want to edit your tags, as they're not really appropriate. Also, this might be of interest to you: http://en.wikipedia.org/wiki/Off-by-one_error. What you're describing is called fencepost error. – rubik Sep 08 '14 at 13:13
  • How can I get the answers for it? How can I frame my question? What tags do you suggest? Yes, I am talking about off-by-one error only. – dexterous Sep 09 '14 at 06:09
  • Well, I don't think there is a unique solution, because the problem you've stated is too general. Also, I would remove the linear-algebra tag. The title is not very catchy, so that's probably why this question has received so few views. Now that you know how these errors are called, you should edit the title. – rubik Sep 09 '14 at 06:56
  • What I can suggest you is to really understand the problem at hand. Do you want to count items? Do you want to count "boundaries"? &c. Take the fencepost problem as a reference. – rubik Sep 09 '14 at 06:57

0 Answers0