source: trunk/sys/dietlibc/__ltostr.c @ 67

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

First import

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