about summary refs log tree commit diff
path: root/absl/numeric/int128.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/numeric/int128.cc')
-rw-r--r--absl/numeric/int128.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/absl/numeric/int128.cc b/absl/numeric/int128.cc
index 7debf56a62b7..5081def5e1b0 100644
--- a/absl/numeric/int128.cc
+++ b/absl/numeric/int128.cc
@@ -187,8 +187,14 @@ std::ostream& operator<<(std::ostream& o, const uint128& b) {
   // Add the requisite padding.
   std::streamsize width = o.width(0);
   if (static_cast<size_t>(width) > rep.size()) {
-    if ((flags & std::ios::adjustfield) == std::ios::left) {
+    std::ios::fmtflags adjustfield = flags & std::ios::adjustfield;
+    if (adjustfield == std::ios::left) {
       rep.append(width - rep.size(), o.fill());
+    } else if (adjustfield == std::ios::internal &&
+               (flags & std::ios::showbase) &&
+               (flags & std::ios::basefield) != std::ios::dec) {
+      size_t base_size = (flags & std::ios::basefield) == std::ios::hex ? 2 : 1;
+      rep.insert(base_size, width - rep.size(), o.fill());
     } else {
       rep.insert(0, width - rep.size(), o.fill());
     }