Go to Post "You know you're a robotics kid when you sit on Chief Delphi and hit refresh over and over again waiting for new pictures and videos of other teams" - pwnageNick [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 22-01-2005, 09:25
psquared psquared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Chantilly
Posts: 34
psquared is an unknown quantity at this point
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);
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.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 10:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi