What you have is undefined behavior the result of:
0.2929 * q
is a double but you are telling printf
it is a unsigned short. If you cast the result to unsigned short you will get the result you expect (see it live):
printf("(sys3.b0 * q) = %hx \n",(unsigned short)(0.2929 * q));
^^^^^^^^^^^^^^^^
Having warning turned on or up should have indicated that this was a problem, both gcc
and clang
give similar errros:
warning: format '%hx' expects argument of type 'int', but argument 2 has type 'double' [-Wformat=]
Although apparently Visual Studio does not.