|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Math Gone Wrong
We have a integer type value called joystick
Code:
joystick = (2)*(p1_x)+256;
printf("joystick: %d p1_x: %d \n", joystick, p1_x);
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. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| New math functions? | KVermilion | Programming | 8 | 17-01-2005 10:38 |
| I-cylinder body wrong? | Daniel Brim | Inventor | 0 | 05-03-2004 20:18 |
| Wrong Math in the site info section.. | Matt Attallah | CD Forum Support | 9 | 10-06-2003 16:43 |
| direct Drill motor drive wrong or right | rcubes85 | General Forum | 6 | 11-02-2003 18:11 |
| Whats wrong with this code? | Morgoth | Programming | 4 | 19-01-2003 11:45 |