[PATCH] itoa

Freddie Chopin freddie_chopin@op.pl
Sun Dec 7 16:46:00 GMT 2014


On 12/07/2014 02:34 PM, Jon Beniston wrote:
> Hi,
>
> The attached patch adds support for the itoa and utoa functions, for
> converting integers to strings.
>
> This is a function that is supported on other platforms, and useful on
> embedded systems where sprintf is quite large and doesn't support binary.
>
> Cheers,
> Jon

Good idea to add that (; I have a _LOT_ of ideas on using them in newlib 
instead of standard functions (;

Anyway - I think itoa() should be implemented as a wrapper for utoa with 
more or less this operations:
- check if base == 10 and value less than 0
- - if yes, add '-' character to the string and move the pointer one 
character further and negate the value
- do the cast to unsigned
- call utoa() (with the modified string pointer).

Regards,
FCh



More information about the Newlib mailing list