ReactOS 0.4.16-dev-819-g75c0dc0
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 (_isnan(arg))
52 {
53 snprintf(buf, ndigits, "1.#QNAN");
54 *decpt = 0;
55 *sign = 0;
56 return buf;
57 }
58 if (!_finite(arg))
59 {
60 snprintf(buf, ndigits, "1.#INF");
61 *decpt = 0;
62 *sign = 0;
63 return buf;
64 }
65
66 if (ndigits >= CVTBUFSIZE - 1) ndigits = CVTBUFSIZE - 2;
67 r2 = 0;
68 *sign = 0;
69 p = &buf[0];
70 if (arg < 0)
71 {
72 *sign = 1;
73 arg = -arg;
74 }
75 arg = modf(arg, &fi);
76 p1 = &buf[CVTBUFSIZE];
77
78 if (fi != 0)
79 {
80 p1 = &buf[CVTBUFSIZE];
81 while (fi != 0)
82 {
83 fj = modf(fi / 10, &fi);
84 *--p1 = (int)((fj + .03) * 10) + '0';
85 r2++;
86 }
87 while (p1 < &buf[CVTBUFSIZE]) *p++ = *p1++;
88 }
89 else if (arg > 0)
90 {
91 while ((fj = arg * 10) < 1)
92 {
93 arg = fj;
94 r2--;
95 }
96 }
97 p1 = &buf[ndigits];
98 if (eflag == 0) p1 += r2;
99 *decpt = r2;
100 if (p1 < &buf[0])
101 {
102 buf[0] = '\0';
103 return buf;
104 }
105 while (p <= p1 && p < &buf[CVTBUFSIZE])
106 {
107 arg *= 10;
108 arg = modf(arg, &fj);
109 *p++ = (int) fj + '0';
110 }
111 if (p1 >= &buf[CVTBUFSIZE])
112 {
113 buf[CVTBUFSIZE - 1] = '\0';
114 return buf;
115 }
116 p = p1;
117 *p1 += 5;
118 while (*p1 > '9')
119 {
120 *p1 = '0';
121 if (p1 > buf)
122 ++*--p1;
123 else
124 {
125 *p1 = '1';
126 (*decpt)++;
127 if (eflag == 0)
128 {
129 if (p > buf) *p = '0';
130 p++;
131 }
132 }
133 }
134 *p = '\0';
135 return buf;
136}
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_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
_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:52
static size_t double int int * decpt
Definition: printf.c:52
void * arg
Definition: msvc.h:10
#define snprintf
Definition: wintirpc.h:48

Referenced by __acrt_GetModuleFileNameA(), _access_s(), _chmod(), _mkdir(), _rmdir(), _sopen_nolock(), common_stat(), fcvtbuf(), get_file_name(), _Locale_impl::insert_ctype_facets(), remove(), and CodecvtTest::special_encodings().

◆ fcvtbuf()

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

Definition at line 138 of file fcvtbuf.c.

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

Referenced by _fcvt().