[libc++][nfc] Move functions to a generic place.

This allows the floating-point formatter to use the same functions as
the integral formatter. This was tested in D114001.

GitOrigin-RevId: ed86610c7bcd5346d05db6a62fce6fb16eb83659
diff --git a/include/__format/formatter.h b/include/__format/formatter.h
index 38fd88e..1adce75 100644
--- a/include/__format/formatter.h
+++ b/include/__format/formatter.h
@@ -60,6 +60,49 @@
   }
 };
 
+namespace __format_spec {
+
+_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative,
+                                                 _Flags::_Sign __sign) {
+  if (__negative)
+    *__buf++ = '-';
+  else
+    switch (__sign) {
+    case _Flags::_Sign::__default:
+    case _Flags::_Sign::__minus:
+      // No sign added.
+      break;
+    case _Flags::_Sign::__plus:
+      *__buf++ = '+';
+      break;
+    case _Flags::_Sign::__space:
+      *__buf++ = ' ';
+      break;
+    }
+
+  return __buf;
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) {
+  switch (c) {
+  case 'a':
+    return 'A';
+  case 'b':
+    return 'B';
+  case 'c':
+    return 'C';
+  case 'd':
+    return 'D';
+  case 'e':
+    return 'E';
+  case 'f':
+    return 'F';
+  }
+  return c;
+}
+
+} // namespace __format_spec
+
 namespace __formatter {
 
 /** The character types that formatters are specialized for. */
diff --git a/include/__format/formatter_integral.h b/include/__format/formatter_integral.h
index 6a232f2..5f1353e 100644
--- a/include/__format/formatter_integral.h
+++ b/include/__format/formatter_integral.h
@@ -133,45 +133,6 @@
          + 1;                        // Reserve space for the sign.
 }
 
-_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative,
-                                                 _Flags::_Sign __sign) {
-  if (__negative)
-    *__buf++ = '-';
-  else
-    switch (__sign) {
-    case _Flags::_Sign::__default:
-    case _Flags::_Sign::__minus:
-      // No sign added.
-      break;
-    case _Flags::_Sign::__plus:
-      *__buf++ = '+';
-      break;
-    case _Flags::_Sign::__space:
-      *__buf++ = ' ';
-      break;
-    }
-
-  return __buf;
-}
-
-_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) {
-  switch (c) {
-  case 'a':
-    return 'A';
-  case 'b':
-    return 'B';
-  case 'c':
-    return 'C';
-  case 'd':
-    return 'D';
-  case 'e':
-    return 'E';
-  case 'f':
-    return 'F';
-  }
-  return c;
-}
-
 /**
  * Determines the required grouping based on the size of the input.
  *