source: trunk/sys/dietlibc/__lltostr.c @ 50

Last change on this file since 50 was 1, checked in by alain, 8 years ago

First import

File size: 499 bytes
Line 
1#include <string.h>
2
3int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase);
4
5int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase)
6{
7  char *tmp;
8  unsigned int j=0;
9
10  s[--size]=0;
11
12  tmp=s+size;
13
14  if ((base==0)||(base>36)) base=10;
15
16  j=0;
17  if (!i)
18  {
19    *(--tmp)='0';
20    j=1;
21  }
22
23  while((tmp>s)&&(i))
24  {
25    tmp--;
26    if ((*tmp=i%base+'0')>'9') *tmp+=(UpCase?'A':'a')-'9'-1;
27    i=i/base;
28    j++;
29  }
30  memmove(s,tmp,j+1);
31
32  return j;
33}
Note: See TracBrowser for help on using the repository browser.