MCPcopy Create free account
hub / github.com/WheretIB/nullc / parseDouble

Function parseDouble

NULLC/Callbacks.cpp:369–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369double parseDouble(const char *str)
370{
371 unsigned int digit;
372 double integer = 0.0;
373 while((digit = *str - '0') < 10)
374 {
375 integer = integer * 10.0 + digit;
376 str++;
377 }
378
379 double fractional = 0.0;
380
381 if(*str == '.')
382 {
383 double power = 0.1f;
384 str++;
385 while((digit = *str - '0') < 10)
386 {
387 fractional = fractional + power * digit;
388 power /= 10.0;
389 str++;
390 }
391 }
392 if(*str == 'e')
393 {
394 str++;
395 if(*str == '-')
396 return (integer + fractional) * pow(10.0, (double)-parseInteger(str+1));
397 else
398 return (integer + fractional) * pow(10.0, (double)parseInteger(str));
399 }
400 return integer + fractional;
401}
402
403// Saves number of defined variables and functions
404void BeginBlock()

Callers 2

AddNumberNodeFloatFunction · 0.85
AddNumberNodeDoubleFunction · 0.85

Calls 1

parseIntegerFunction · 0.85

Tested by

no test coverage detected