Jump to content

Sprintf32 Bug?


Recommended Posts

Hi All

 

I think this shows a lib / compiler bug. If you run this code in the debuger (and on a real PIC18F) then the 32 bit function produces an error.

 

sprintf32 gives 999

sprintf gives 9999

 

So, sprintf32 misses out one digit. It only seems to do this for numbers over 99. I have not looked at negative numbers

 

Can this be confirmed as a bug? If so can it be fixed?

 

Thanks

 

Neil

 

OS XPpro, BoostC++ 6.90 PIC18f8722

 

 

	char buf[64];
char* bufP = buf;

unsigned long tl = 9999;
sprintf32(bufP, "%d", tl);

unsigned int ti = 9999;
sprintf(bufP, "%d", ti);

 

I know I dot need bufP but this helps the debugger show the text string in the watch window.

 

 

I have now compiled the sprintf32 code in libc and this works just fine for me.

Edited by Pavel
fixed "funny" characters in the sample code
Link to post
Share on other sites
  • 3 years later...

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...