Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / lib / msvcrt / stdlib / gcvt.c
1 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
2 #include <msvcrti.h>
3
4
5 char *
6 _gcvt (double value, int ndigits, char *buf)
7 {
8 char *p = buf;
9
10 sprintf (buf, "%-#.*g", ndigits, value);
11
12 /* It seems they expect us to return .XXXX instead of 0.XXXX */
13 if (*p == '-')
14 p++;
15 if (*p == '0' && p[1] == '.')
16 memmove (p, p + 1, strlen (p + 1) + 1);
17
18 /* They want Xe-YY, not X.e-YY, and XXXX instead of XXXX. */
19 p = strchr (buf, 'e');
20 if (!p)
21 {
22 p = buf + strlen (buf);
23 /* They don't want trailing zeroes. */
24 while (p[-1] == '0' && p > buf + 2)
25 *--p = '\0';
26 }
27 if (p > buf && p[-1] == '.')
28 memmove (p - 1, p, strlen (p) + 1);
29 return buf;
30 }