Re: [Libclc-developers] CLC_FAST & clc_ultostr (Was: new function: clc_strrev)
Status: Planning
Brought to you by:
augestad
|
From: Hallvard B F. <h.b...@us...> - 2003-03-28 18:32:16
|
Bj=F8rn Augestad writes:
>Hallvard B Furuseth wrote:
>> Anyway, shall I check it in? =20
> Yes.
Done.
I also made it handle size =3D=3D 1, since it took no extra object code.
Also, here are some fixes to the documentation.
NAME
clc_ultostr - convert an unsigned long integer to a string
SYNOPSIS
char *clc_ultostr(char *ptr, size_t size, unsigned long num
int base);
DESCRIPTION
The clc_ultostr() function converts the number NUM to a string, in
base BASE notation. BASE must be between 2 and 36 inclusive. SIZE
must be at least 1. To summarize it, this function does (nearly)
exactly the opposite of strtoul().
The output and a trailing '\0' is stored in a buffer pointed to by
PTR, whose total length is passed in SIZE. If SIZE is too small,
the result is truncated and only the least significant digits are
stored.
RETURN VALUE
clc_ultostr() returns 1 on success, or 0 if truncation happened.
EXAMPLE
unsigned char buf[12];
/* print 10101010 */
clc_ultostr_n(buf, sizeof(buf), 170, 2);
puts(buf);
/* print 1Y */
clc_ultostr_n(buf, sizeof(buf), 70, 36);
puts(buf);
--=20
Hallvard
|