ReactOS 0.4.16-dev-257-g6aa11ac
fcvtbuf.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <malloc.h>
Include dependency graph for fcvtbuf.c:

Go to the source code of this file.

Macros

#define CVTBUFSIZE   2 * DBL_MAX_10_EXP + 10
 

Functions

static charcvt (double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag)
 
charfcvtbuf (double arg, int ndigits, int *decpt, int *sign, char *buf)
 

Macro Definition Documentation

◆ CVTBUFSIZE

#define CVTBUFSIZE   2 * DBL_MAX_10_EXP + 10

Definition at line 44 of file fcvtbuf.c.

Function Documentation

◆ cvt()

static char * cvt ( double  arg,
int  ndigits,
int decpt,
int sign,
char buf,
int  eflag 
)
static

Definition at line 45 of file fcvtbuf.c.

46{
47 int r2;
48 double fi, fj;
49 char *p, *p1;
50
51 if (ndigits >= CVTBUFSIZE - 1) ndigits = CVTBUFSIZE - 2;
52 r2 = 0;
53 *sign = 0;
54 p = &buf[0];
55 if (arg < 0)
56 {
57 *sign = 1;
58 arg = -arg;
59 }
60 arg = modf(arg, &fi);
61 p1 = &buf[CVTBUFSIZE];
62
63 if (fi != 0)
64 {
65 p1 = &buf[CVTBUFSIZE];
66 while (fi != 0)
67 {
68 fj = modf(fi / 10, &fi);
69 *--p1 = (int)((fj + .03) * 10) + '0';
70 r2++;
71 }
72 while (p1 < &buf[CVTBUFSIZE]) *p++ = *p1++;
73 }
74 else if (arg > 0)
75 {
76 while ((fj = arg * 10) < 1)
77 {
78 arg = fj;
79 r2--;
80 }
81 }
82 p1 = &buf[ndigits];
83 if (eflag == 0) p1 += r2;
84 *decpt = r2;
85 if (p1 < &buf[0])
86 {
87 buf[0] = '\0';
88 return buf;
89 }
90 while (p <= p1 && p < &buf[CVTBUFSIZE])
91 {
92 arg *= 10;
93 arg = modf(arg, &fj);
94 *p++ = (int) fj + '0';
95 }
96 if (p1 >= &buf[CVTBUFSIZE])
97 {
98 buf[CVTBUFSIZE - 1] = '\0';
99 return buf;
100 }
101 p = p1;
102 *p1 += 5;
103 while (*p1 > '9')
104 {
105 *p1 = '0';
106 if (p1 > buf)
107 ++*--p1;
108 else
109 {
110 *p1 = '1';
111 (*decpt)++;
112 if (eflag == 0)
113 {
114 if (p > buf) *p = '0';
115 p++;
116 }
117 }
118 }
119 *p = '\0';
120 return buf;
121}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define CVTBUFSIZE
Definition: fcvtbuf.c:44
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)
#define sign(x)
Definition: mapdesc.cc:613
static DNS_RECORDW r2
Definition: record.c:38
static size_t double int ndigits
Definition: printf.c:72
static size_t double int int * decpt
Definition: printf.c:72
void * arg
Definition: msvc.h:10

Referenced by fcvtbuf(), _Locale_impl::insert_ctype_facets(), and CodecvtTest::special_encodings().

◆ fcvtbuf()

char * fcvtbuf ( double  arg,
int  ndigits,
int decpt,
int sign,
char buf 
)

Definition at line 123 of file fcvtbuf.c.

124{
125 return cvt(arg, ndigits, decpt, sign, buf, 0);
126}
static char * cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag)
Definition: fcvtbuf.c:45

Referenced by _fcvt().