We have a integer type value called joystick
Code:
joystick = (2)*(p1_x)+256;
printf("joystick: %d p1_x: %d \n", joystick, p1_x);
When this code runs here is a sample output:
p1_x joystick
0 256 works like it should (2)*(0)+256
50 356 works fine: 2*50+256=100+256=356
127 510 works fine: 2*127+256=254+256=510
128 256 ***DOESN"T WORK****
200 400 ***DOESN'T WORK****
250 500 ***DOESN't WORK****
for some reason the code only works for p1_x is less than 128, otherwise after it is greater than or equal to 128 it just doubles it. Can anyone explain why, and what a solution might be, thanks.