add deprecated (removed from posix) [efg]cvt() functions
[musl] / src / stdlib / ecvt.c
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 char *ecvt(double x, int n, int *dp, int *sign)
5 {
6         static char buf[16];
7         char tmp[32];
8         int i, j;
9
10         if (n-1U > 15) n = 15;
11         sprintf(tmp, "%.*e", n-1, x);
12         i = *sign = (tmp[0]=='-');
13         for (j=0; tmp[i]!='e'; j+=(tmp[i++]!='.'))
14                 buf[j] = tmp[i];
15         buf[j] = 0;
16         *dp = atoi(tmp+i+1);
17
18         return buf;
19 }