View previous topic :: View next topic |
Author |
Message |
wb7ubb
Joined: 03 Oct 2012 Posts: 2
|
Need help with addition, I guess |
Posted: Wed Oct 03, 2012 8:56 pm |
|
|
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
|
|
Posted: Wed Oct 03, 2012 9:27 pm |
|
|
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
|
Your Awesome! |
Posted: Wed Oct 03, 2012 11:48 pm |
|
|
Thank you! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
Re: Your Awesome! |
Posted: Thu Oct 04, 2012 12:38 am |
|
|
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 |
|
|
|