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.
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%.
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.
ReplyDeleteI 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