277 {
278 if (!str) {
279 if (endptr) {
280 *endptr = const_cast<char*>(str);
281 }
282 return 0.0;
283 }
284
285 const char* p = str;
287 bool negative = false;
288
289
290 while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || *p == '\f' || *p == '\v') {
291 p++;
292 }
293
294
295 if (*p == '-') {
296 negative = true;
297 p++;
298 } else if (*p == '+') {
299 p++;
300 }
301
302 const char* start = p;
303
304
305 while (*p >= '0' && *p <= '9') {
307 p++;
308 }
309
310
311 if (*p == '.') {
312 p++;
313 double fraction = 0.1;
314 while (*p >= '0' && *p <= '9') {
315 result += (*p -
'0') * fraction;
316 fraction *= 0.1;
317 p++;
318 }
319 }
320
321
322 if (*p == 'e' || *p == 'E') {
323 p++;
324 bool expNegative = false;
325 if (*p == '-') {
326 expNegative = true;
327 p++;
328 } else if (*p == '+') {
329 p++;
330 }
331
333 while (*p >= '0' && *p <= '9') {
334 exp =
exp * 10 + (*p -
'0');
335 p++;
336 }
337
338 double multiplier = 1.0;
339 for (
int i = 0; i <
exp; i++) {
340 multiplier *= 10.0;
341 }
342
343 if (expNegative) {
345 } else {
347 }
348 }
349
350
351 if (endptr) {
352 if (p == start) {
353 *endptr = const_cast<char*>(str);
354 } else {
355 *endptr = const_cast<char*>(p);
356 }
357 }
358
360}
expected< T, E > result
Alias for expected (Rust-style naming)
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NO_EXCEPT