This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] itoa


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]