MCPcopy Create free account
hub / github.com/ablab/spades / interpretDecimal

Function interpretDecimal

ext/src/llvm/APFloat.cpp:376–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374};
375
376static Error interpretDecimal(StringRef::iterator begin,
377 StringRef::iterator end, decimalInfo *D) {
378 StringRef::iterator dot = end;
379
380 auto PtrOrErr = skipLeadingZeroesAndAnyDot(begin, end, &dot);
381 if (!PtrOrErr)
382 return PtrOrErr.takeError();
383 StringRef::iterator p = *PtrOrErr;
384
385 D->firstSigDigit = p;
386 D->exponent = 0;
387 D->normalizedExponent = 0;
388
389 for (; p != end; ++p) {
390 if (*p == '.') {
391 if (dot != end)
392 return createError("String contains multiple dots");
393 dot = p++;
394 if (p == end)
395 break;
396 }
397 if (decDigitValue(*p) >= 10U)
398 break;
399 }
400
401 if (p != end) {
402 if (*p != 'e' && *p != 'E')
403 return createError("Invalid character in significand");
404 if (p == begin)
405 return createError("Significand has no digits");
406 if (dot != end && p - begin == 1)
407 return createError("Significand has no digits");
408
409 /* p points to the first non-digit in the string */
410 auto ExpOrErr = readExponent(p + 1, end);
411 if (!ExpOrErr)
412 return ExpOrErr.takeError();
413 D->exponent = *ExpOrErr;
414
415 /* Implied decimal point? */
416 if (dot == end)
417 dot = p;
418 }
419
420 /* If number is all zeroes accept any exponent. */
421 if (p != D->firstSigDigit) {
422 /* Drop insignificant trailing zeroes. */
423 if (p != begin) {
424 do
425 do
426 p--;
427 while (p != begin && *p == '0');
428 while (p != begin && *p == '.');
429 }
430
431 /* Adjust the exponents for any decimal point. */
432 D->exponent += static_cast<APFloat::ExponentType>((dot - p) - (dot > p));
433 D->normalizedExponent = (D->exponent +

Callers 1

Calls 5

createErrorFunction · 0.85
decDigitValueFunction · 0.85
readExponentFunction · 0.85
takeErrorMethod · 0.45

Tested by

no test coverage detected