Go to Post Come on, guys, it's two weeks 'til build. Personally, I'm gonna go outside for a little before I forget what my neighborhood looks like in the daylight. :) - Libby K [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 23-02-2008, 00:47
1jbinder 1jbinder is offline
Registered User
FRC #0852
 
Join Date: Jan 2008
Location: Athenian School
Posts: 35
1jbinder is an unknown quantity at this point
Operator/Bit Issue

Hi,

We are having a really unique problem that has stumped the whole programing team, all of the mentors, and the team leader. We are trying to write some code in MPLab to calculate the number of encoder ticks needed to reach six feet. We have found that fourteen encoder clicks is the same as one inch. The problem comes in when we try to multiply 72(six feet in inches) by 14(clicks in an inch). When this happens we get -16 which is 32 bits off. We are using the variable type long. Below is the code that we have written:

long atemp=0;
atemp=14*72;//should be 1008
printf("atemp=%ld\r\n", atemp);

This code did not work and gave us a value of -16 for atemp. We also tried this:

long atemp=0;
atemp=72+72+72+72+72+72+72+72+72+72+72+72+72+72;
printf("atemp=%ld\r\n", atemp);

This also did not work and gave us a value of -16. Adding smaller numbers works fine and multiplying smaller numbers also works. We have pretty much exhausted any ideas.
Thanks,
Julian
 


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
pic: A "Bit" of a problem. Herodotus Extra Discussion 26 11-10-2007 01:53
A bit of humor... 114Klutz Chit-Chat 0 01-04-2006 17:34
Operator Interface power ISSUE kacz100 Technical Discussion 11 27-02-2004 13:46
A bit unfair... Martin General Forum 61 26-02-2002 07:48
i am a bit miffed Zeinin 3D Animation and Competition 3 18-01-2002 13:39


All times are GMT -5. The time now is 09:45.

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