ReactOS  0.4.14-dev-342-gdc047f9
gcvt.c
Go to the documentation of this file.
1 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
2 #include <precomp.h>
3 
4 /*
5  * @implemented
6  */
7 char *
8 _gcvt (double value, int ndigits, char *buf)
9 {
10  char *p = buf;
11 
12  sprintf (buf, "%-#.*g", ndigits, value);
13 
14  /* It seems they expect us to return .XXXX instead of 0.XXXX */
15  if (*p == '-')
16  p++;
17  if (*p == '0' && p[1] == '.')
18  memmove (p, p + 1, strlen (p + 1) + 1);
19 
20  /* They want Xe-YY, not X.e-YY, and XXXX instead of XXXX. */
21  p = strchr (buf, 'e');
22  if (!p)
23  {
24  p = buf + strlen (buf);
25  /* They don't want trailing zeroes. */
26  while (p[-1] == '0' && p > buf + 2)
27  *--p = '\0';
28  }
29  if (p > buf && p[-1] == '.')
30  memmove (p - 1, p, strlen (p) + 1);
31  return buf;
32 }
char * _gcvt(double value, int ndigits, char *buf)
Definition: gcvt.c:8
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static size_t double int ndigits
Definition: printf.c:69
char * strchr(const char *String, int ch)
Definition: utclib.c:501
GLfloat GLfloat p
Definition: glext.h:8902