aboutsummaryrefslogtreecommitdiff
path: root/libc/stdlib.c
blob: 356fc33ccf4e83db920c7517c6a770b69fa07961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdlib.h>

/* adapted from <http://www.strudel.org.uk/itoa/> */
char* itoa(int val, int base)
{
    static char buf[32] = {0};

    int i = 30;

    for(; val && i ; --i, val /= base)

        buf[i] = "0123456789abcdef"[val % base];

    return &buf[i+1];
}