home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
LTOA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
849b
|
52 lines
#include <string.h>
#ifdef __STRICT_ANSI__
# ifdef __GNUC__
char * strrev(char *);
# else
extern char * strrev();
# endif
#endif
char _numstr[] = "0123456789ABCDEF";
char *_ultoa(n, buffer, radix)
register unsigned long n;
register char *buffer;
register int radix;
{
register char *p = buffer;
do
{
*p++ = _numstr[n % radix]; /* grab each digit */
}
while((n /= radix) > 0);
*p = '\0';
return(strrev(buffer)); /* reverse and return it */
}
char *_ltoa(n, buffer, radix)
register long n;
register char *buffer;
int radix;
{
register char *p = buffer;
if (n < 0)
{
*p++ = '-';
n = -n;
}
_ultoa(n, p, radix);
return(buffer);
}
char *_itoa(n, buffer, radix)
int n;
char *buffer;
int radix;
{
return(_ltoa(((long) n), buffer, radix));
}