ReactOS  0.4.15-dev-2522-g9e0a3cd
gcvt.c File Reference
#include <precomp.h>
Include dependency graph for gcvt.c:

Go to the source code of this file.

Functions

char_gcvt (double value, int ndigits, char *buf)
 

Function Documentation

◆ _gcvt()

char* _gcvt ( double  value,
int  ndigits,
char buf 
)

Definition at line 8 of file gcvt.c.

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 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
Definition: pdh_main.c:93
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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