OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [misc/] [ltostr.c] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
2
 * This file is part of the Linux-8086 C library and is distributed
3
 * under the GNU Library General Public License.
4
 */
5
 
6
static char buf[34];
7
 
8
extern char * ultostr();
9
 
10
char * ltostr(val, radix, uppercase)
11
long val;
12
int radix;
13
int uppercase;
14
{
15
   char *p;
16
   int flg = 0;
17
   if( val < 0 ) { flg++; val= -val; }
18
   p = ultostr(val, radix, uppercase);
19
   if(p && flg) *--p = '-';
20
   return p;
21
}
22
 
23
char * ultostr(val, radix, uppercase)
24
unsigned long val;
25
int radix;
26
int uppercase;
27
{
28
   register char *p;
29
   register int c;
30
 
31
   if( radix > 36 || radix < 2 ) return 0;
32
 
33
   p = buf+sizeof(buf);
34
   *--p = '\0';
35
 
36
   do
37
   {
38
      c = val%radix;
39
      val/=radix;
40
      if( c > 9 ) *--p = (uppercase ? 'A' : 'a')-10+c; else *--p = '0'+c;
41
   }
42
   while(val);
43
   return p;
44
}
45
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.