diff options
author | Dale Johannesen <dalej@apple.com> | 2007-08-31 04:03:46 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-08-31 04:03:46 +0000 |
commit | eaf089430e7681fcddc3465c3b33b9645273ab02 (patch) | |
tree | 426df38ac585285c3b18e3b4575b297fcd4d9e59 /include/llvm/ADT/StringExtras.h | |
parent | 8c132633c86a7e496f84e3458c47520d0cc4d938 (diff) | |
download | llvm-eaf089430e7681fcddc3465c3b33b9645273ab02.tar.gz llvm-eaf089430e7681fcddc3465c3b33b9645273ab02.tar.bz2 llvm-eaf089430e7681fcddc3465c3b33b9645273ab02.tar.xz |
Enhance APFloat to retain bits of NaNs (fixes oggenc).
Use APFloat interfaces for more references, mostly
of ConstantFPSDNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringExtras.h')
-rw-r--r-- | include/llvm/ADT/StringExtras.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index f0788a1b11..b56c183a79 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -15,6 +15,7 @@ #define LLVM_ADT_STRINGEXTRAS_H #include "llvm/Support/DataTypes.h" +#include "llvm/ADT/APFloat.h" #include <cctype> #include <cstdio> #include <string> @@ -92,6 +93,14 @@ static inline std::string ftostr(double V) { return B; } +static inline std::string ftostr(APFloat V) { + if (&V.getSemantics() == &APFloat::IEEEsingle) + return ftostr(V.convertToDouble()); + else if (&V.getSemantics() == &APFloat::IEEEdouble) + return ftostr((double)V.convertToFloat()); + return 0; // error +} + static inline std::string LowercaseString(const std::string &S) { std::string result(S); for (unsigned i = 0; i < S.length(); ++i) |