Consider the following C code:
int c=((0xa3>>6)&0x1f)|0xc0;
printf("%d\n",c);
It correctly prints out 194 (0xc2). If I write the same thing in wcalc, the result is 195, or 0xc3. Is this some sort of precision error? Is this expected behavior? floor and ceiling functions do not work… or, to be more specific, floor works for 0xa3, but not for, say 0xa1, and vice versa.
Any help appreciated. Thanks.
In effect, wcalc treats
x >> ynot as an integer bitshift operator (which simply drops shifted bits off the right hand side) but as floating-point division of x by 2^y. Hence:And this explains the difference relative to the C version, where
0xa3 >> 6is simply 2.