diff options
Diffstat (limited to 'lib/string')
-rw-r--r-- | lib/string/itoa.c | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/lib/string/itoa.c b/lib/string/itoa.c deleted file mode 100644 index 2db9768..0000000 --- a/lib/string/itoa.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <stdbool.h> -#include <string.h> - -static const char *numbers = "0123456789abcdef"; - -char * -utoa(char *p, unsigned x, int base) -{ - p += 3 * sizeof(unsigned); - *--p = '\0'; - - do { - *--p = numbers[x % base]; - x /= base; - } while (x); - - return p; -} - -char * -itoa(char *p, int x, int base) -{ - const bool is_negative = (x < 0); - if (is_negative) x = -x; - - p = utoa(p, x, base); - - if (is_negative) *--p = '-'; - return p; -} |