|
|
|
|
|
by cautious_int
3957 days ago
|
|
Actually it is misleading by them( and you ) to assume that in C, an unsigned int can represent values larger than the largest signed int value. In other words, C allows that UINT_MAX == INT_MAX, in which case you will overflow. If they made that assumption, they should explicitly mention it, but they didn't. > Update 17 Feb 2008:... ...Now that we've made this change, we know that the program is correct;) It seems the article is aware of the irony. Another update would be in order. |
|
Also I'm not trying to mislead people into thinking that its a good way to implement this. The confounding bit from the article is they started in Java and ended up in C. If you were indexing with signed ints in C, C++, or any language that has unsigned integers then you already have a bug with or without the bad mean check.