A variable shifted right seems to result in an incorrect value.
uint64_t i = 13,825,587,238; i = i >> 7u;
The situation is observed when 13,825,587,238 is right shifted 7. The correct value is 10,473,877,732 but debug window has 12,992,914,288.
http://youtu.be/szgss6lDotU
Would this be a syntax error?
The debugger has presented the result of the original high 32 bits concatenated with post-shift low 32 bits.
Ah. I see. Your original post was all wrong (face-palm).
Isn't a right shift by 7 the same as dividing by 2 to the power of 7 (so 128)?
Shouldn't the correct answer be 108,012,400?
you should specify that your constants are long long
This is true such as 8LL or 8ULL. However, it does not change the shift result. The shift output is incorrect.
Note that for a 32-bit compilation you should specify that your constants are long long (or maybe unsigned long long) when you play with 64-bit constants.
The result of the right shift is incorrect. The incorrect value is shown in the Youtube capture.
13,825,587,238 >> 7 Correct value - 108,012,400 Keil Debugger Value - 12,992,914,288
Are you really sure that either result is correct?
View all questions in Keil forum