Changeset View
Changeset View
Standalone View
Standalone View
libscience/parser.cpp
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
102 | if (!isdigit(m_nextChar)) { | 102 | if (!isdigit(m_nextChar)) { | ||
103 | return false; | 103 | return false; | ||
104 | } | 104 | } | ||
105 | 105 | | |||
106 | double result = 0.0; | 106 | double result = 0.0; | ||
107 | 107 | | |||
108 | // The integer. | 108 | // The integer. | ||
109 | while (isdigit(m_nextChar)) { | 109 | while (isdigit(m_nextChar)) { | ||
110 | result = result * 10.0 + (double)(m_nextChar - '0'); | 110 | result = result * 10.0 + static_cast<double>(m_nextChar - '0'); | ||
111 | getNextChar(); | 111 | getNextChar(); | ||
112 | } | 112 | } | ||
113 | *_result = result; | 113 | *_result = result; | ||
114 | 114 | | |||
115 | if (m_nextChar != '.' || !isdigit(getNextChar())) { | 115 | if (m_nextChar != '.' || !isdigit(getNextChar())) { | ||
116 | *_result = sign * result; | 116 | *_result = sign * result; | ||
117 | return true; | 117 | return true; | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | double decimal = 0.1; | 120 | double decimal = 0.1; | ||
121 | while (isdigit(m_nextChar)) { | 121 | while (isdigit(m_nextChar)) { | ||
122 | result += decimal * (double)(m_nextChar - '0'); | 122 | result += decimal * static_cast<double>(m_nextChar - '0'); | ||
123 | decimal /= 10.0; | 123 | decimal /= 10.0; | ||
124 | getNextChar(); | 124 | getNextChar(); | ||
125 | } | 125 | } | ||
126 | 126 | | |||
127 | *_result = sign * result; | 127 | *_result = sign * result; | ||
128 | return true; | 128 | return true; | ||
129 | } | 129 | } | ||
130 | 130 | | |||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |