use warning level 4 (/W4), can be found in C/C++, General, Warning level
assuming score is signed, you have a little problem (or not if you don't care about subtle inaccuracy or if score is unsigned)
arithmetic shift right rounds towards -infinity (assuming 2's complement standard representation)
while this property may be beneficial depending on what you do
EDIT: with fixed point, this is useful because (score+128) >> 8 rounds to nearest integer (but one has to be careful to avoid overflow)
-1 >> 8 = -1 but +1 >> 8 = 0, so you'll get different scores (off by 1 unit) depending on color
score/256 gives the expected result, but the compiler needs to efficiently encode something like this:
Code: Select all
(score + 255*(score<0)) >> 8
of course, it will do better than literally doing this but worse than plain >>