[llvm] [APFloat] Add APFloat::format (PR #99088)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 00:28:52 PDT 2024


================
@@ -5323,6 +5399,291 @@ APFloat APFloat::getAllOnesValue(const fltSemantics &Semantics) {
   return APFloat(Semantics, APInt::getAllOnes(Semantics.sizeInBits));
 }
 
+SmallVectorImpl<char> &APFloat::format(SmallVectorImpl<char> &strout,
+                                       llvm::FloatStyle style,
+                                       std::optional<size_t> precision_in) {
+  size_t precision = precision_in.value_or(getDefaultPrecision(style));
+
+  // everything that follows assumes that precision >= 0
+  assert(precision >= 0);
+
+  // deal with the special cases
+  if (isNaN()) {
+    detail::append(strout, "nan");
+    return strout;
+  } else if (isInfinity()) {
----------------
arsenm wrote:

No else after return 

https://github.com/llvm/llvm-project/pull/99088


More information about the llvm-commits mailing list