3 <<itoa>>---integer to string
10 char *itoa(int <[value]>, char *<[str]>, int <[base]>);
11 char *__itoa(int <[value]>, char *<[str]>, int <[base]>);
14 <<itoa>> converts the integer <[value]> to a null-terminated string
15 using the specified base, which must be between 2 and 36, inclusive.
16 If <[base]> is 10, <[value]> is treated as signed and the string will be
17 prefixed with '-' if negative. For all other bases, <[value]> is treated as
18 unsigned. <[str]> should be an array long enough to contain the converted
19 value, which in the worst case is sizeof(int)*8+1 bytes.
22 A pointer to the string, <[str]>, or NULL if <[base]> is invalid.
27 No supporting OS subroutine calls are required.
40 /* Check base is supported. */
41 if ((base
< 2) || (base
> 36))
47 /* Negative numbers are only supported for decimal.
48 * Cast to unsigned to avoid overflow for maximum negative value. */
49 if ((base
== 10) && (value
< 0))
52 uvalue
= (unsigned)-value
;
55 uvalue
= (unsigned)value
;
57 __utoa (uvalue
, &str
[i
], base
);
66 return __itoa (value
, str
, base
);