View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Is this a bug or a feature of sprintf? |
Posted: Thu Feb 28, 2008 8:47 pm |
|
|
Code: | int32 iADC; // 24-bit value from an external ADC AD7718, MSByte is always 0
// read the ADC
sprintf(strOut, "%6LX", iADC); |
Expected: 6 hexadecimal characters
Actual: 8 hexadecimal characters
PCWH 3.240, PIC18LF4520 _________________ Read the label, before opening a can of worms. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 28, 2008 9:57 pm |
|
|
See the test program shown below:
vs. 3.240 displays this:
vs. 3.249 displays this:
vs. 4.068 displays this:
Code: | #include <18F452.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//====================================
void main()
{
int32 iADC;
char strOut[20];
iADC = 0x00123456;
sprintf(strOut, "%6LX", iADC);
printf(strOut);
while(1);
} |
|
|
|
|
|
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
|