CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Need help with addition, I guess

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wb7ubb



Joined: 03 Oct 2012
Posts: 2

View user's profile Send private message

Need help with addition, I guess
PostPosted: Wed Oct 03, 2012 8:56 pm     Reply with quote

i is a byte
value is a long 3
code is a long 0x0000

I'm checking the first digit in a 4 digit code to see if its 0, if so add 0x1000 value times and put the result in code. When I am done with this, code still printf's as a 0000. printf("%4x\r", code); when it should be 3000 if value is 3, right? Please help.
Code:

 if ((code && 0XF000) == 0)       // First Digit
  for (i=1;i<=value;++i)
   code += 0x1000;
  goto Getout;

Thank you,

Brian
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 03, 2012 9:27 pm     Reply with quote

Quote:

code is a long.

printf("%4x\r", code);

Download the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in the printf section at the list of format specifiers that are
used to display the various data types. Find the correct format
string to display a "Hex long int". Then use it instead of what you
have above.
wb7ubb



Joined: 03 Oct 2012
Posts: 2

View user's profile Send private message

Your Awesome!
PostPosted: Wed Oct 03, 2012 11:48 pm     Reply with quote

Thank you!
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

Re: Your Awesome!
PostPosted: Thu Oct 04, 2012 12:38 am     Reply with quote

Additional (and amusing) study:


http://www.youtube.com/watch?v=UIKGV2cTgqA

Enjoy
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group