mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-30 04:35:00 +00:00
[APFloat] Added support for parsing float strings which contain {inf,-inf,NaN,-NaN}.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184713 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fdec0c7a73
commit
575694b6a7
@ -510,6 +510,7 @@ private:
|
||||
/// \name Miscellany
|
||||
/// @{
|
||||
|
||||
bool convertFromStringSpecials(StringRef str);
|
||||
opStatus normalize(roundingMode, lostFraction);
|
||||
opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract);
|
||||
cmpResult compareAbsoluteValue(const APFloat &) const;
|
||||
|
@ -2575,11 +2575,40 @@ APFloat::convertFromDecimalString(StringRef str, roundingMode rounding_mode)
|
||||
return fs;
|
||||
}
|
||||
|
||||
bool
|
||||
APFloat::convertFromStringSpecials(StringRef str) {
|
||||
if (str.equals("inf") || str.equals("INFINITY")) {
|
||||
makeInf(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str.equals("-inf") || str.equals("-INFINITY")) {
|
||||
makeInf(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str.equals("nan") || str.equals("NaN")) {
|
||||
makeNaN(false, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str.equals("-nan") || str.equals("-NaN")) {
|
||||
makeNaN(false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
APFloat::opStatus
|
||||
APFloat::convertFromString(StringRef str, roundingMode rounding_mode)
|
||||
{
|
||||
assert(!str.empty() && "Invalid string length");
|
||||
|
||||
// Handle special cases.
|
||||
if (convertFromStringSpecials(str))
|
||||
return opOK;
|
||||
|
||||
/* Handle a leading minus sign. */
|
||||
StringRef::iterator p = str.begin();
|
||||
size_t slen = str.size();
|
||||
|
Loading…
x
Reference in New Issue
Block a user