Monday, October 8, 2012

Even Microsoft's Programmers Get Simple Things Wrong

In CS classes, we're always taught to mind our edge cases. Looks like someone forgot to match beginning at 1 instead of 0 or vice versa.

2 comments:

  1. I would bet this is more of a floating point arithmetic issue instead of an off-by-1 issue. Going with straight integer arithmetic (100*wins/count) would yield the correct percentage, assuming no overflows. I'm really curious what code you're envisioning that this would be an off-by-1 error.

    ReplyDelete
    Replies
    1. I was thinking that it's indicating he's played only 100 games, but in the percentage calculation they're including the game he's just played without incrementing the counter displayed to the user on that screen. So 19/101 = 18.81% and truncation of the floating point decimal, like you were saying, would result in an 18%.

      Delete