ReactOS 0.4.15-dev-5672-gf73ac17
strtod.c
Go to the documentation of this file.
1/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
2/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
3
4#include <precomp.h>
5
6/*
7 * @implemented
8 */
9double
10strtod(const char *s, char **sret)
11{
12 long double r; /* result */
13 int e; /* exponent */
14 long double d; /* scale */
15 int sign; /* +- 1.0 */
16 int esign;
17 int i;
18 int flags=0;
19
20 r = 0.0;
21 sign = 1;
22 e = 0;
23 esign = 1;
24
25 if (s == NULL)
26 return r;
27
28
29 while ((*s == ' ') || (*s == '\t'))
30 s++;
31
32 if (*s == '+')
33 s++;
34 else if (*s == '-')
35 {
36 sign = -1;
37 s++;
38 }
39
40 while ((*s >= '0') && (*s <= '9'))
41 {
42 flags |= 1;
43 r *= 10.0;
44 r += *s - '0';
45 s++;
46 }
47
48 if (*s == '.')
49 {
50 d = 0.1L;
51 s++;
52 while ((*s >= '0') && (*s <= '9'))
53 {
54 flags |= 2;
55 r += d * (*s - '0');
56 s++;
57 d *= 0.1L;
58 }
59 }
60
61 if (flags == 0)
62 {
63 if (sret)
64 *sret = (char *)s;
65 return 0;
66 }
67
68 if ((*s == 'e') || (*s == 'E'))
69 {
70 s++;
71 if (*s == '+')
72 s++;
73 else if (*s == '-')
74 {
75 s++;
76 esign = -1;
77 }
78 if ((*s < '0') || (*s > '9'))
79 {
80 if (sret)
81 *sret = (char *)s;
82 return r;
83 }
84
85 while ((*s >= '0') && (*s <= '9'))
86 {
87 e *= 10;
88 e += *s - '0';
89 s++;
90 }
91 }
92
93 if (esign < 0)
94 for (i = 1; i <= e; i++)
95 r *= 0.1L;
96 else
97 for (i = 1; i <= e; i++)
98 r *= 10.0;
99
100 if (sret)
101 *sret = (char *)s;
102 return r * sign;
103}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define sign(x)
Definition: mapdesc.cc:613
double strtod(const char *s, char **sret)
Definition: strtod.c:10