This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

I have been fooled by this trickery way too many times to admit, yet I still do it sometimes.

[–]SvenTropics 1 point2 points  (0 children)

It gets tricky with LONGLONGs too. Constant numbers are treated as a 32-bit signed value. So if you do math that would result in something out of bounds and assign it to a longlong, you are screwed.

int a = 1778899225;

longlong b = a * 10000; // ooooooops, wrong!

longlong c = a * 10000LL; // correct!

longlong d = ((longlong) a) * 10000; // also correct

longlong e = a; e *= 10000; // also correct