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

Method convertFromString

ext/src/llvm/APFloat.cpp:2863–2891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2861}
2862
2863Expected<IEEEFloat::opStatus>
2864IEEEFloat::convertFromString(StringRef str, roundingMode rounding_mode) {
2865 if (str.empty())
2866 return createError("Invalid string length");
2867
2868 // Handle special cases.
2869 if (convertFromStringSpecials(str))
2870 return opOK;
2871
2872 /* Handle a leading minus sign. */
2873 StringRef::iterator p = str.begin();
2874 size_t slen = str.size();
2875 sign = *p == '-' ? 1 : 0;
2876 if (*p == '-' || *p == '+') {
2877 p++;
2878 slen--;
2879 if (!slen)
2880 return createError("String has no digits");
2881 }
2882
2883 if (slen >= 2 && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
2884 if (slen == 2)
2885 return createError("Invalid string");
2886 return convertFromHexadecimalString(StringRef(p + 2, slen - 2),
2887 rounding_mode);
2888 }
2889
2890 return convertFromDecimalString(StringRef(p, slen), rounding_mode);
2891}
2892
2893/* Write out a hexadecimal representation of the floating point value
2894 to DST, which must be of sufficient size, in the C99 form

Callers 1

getAsDoubleMethod · 0.80

Calls 8

createErrorFunction · 0.85
assertClass · 0.85
DoubleAPFloatClass · 0.85
StringRefClass · 0.70
emptyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
bitcastToAPIntMethod · 0.45

Tested by

no test coverage detected