[libcxx-commits] [PATCH] D128929: [libc++] Implements 128-bit support in to_chars.

Nilay Vaish via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 6 12:40:55 PDT 2022


nilayvaish added inline comments.


================
Comment at: libcxx/include/__charconv/to_chars_base_10.h:151
+  // Maximum unsigned values
+  // 64  bit                              8'446'744'073'709'551'615 (19 digits)
+  // 128 bit    340'282'366'920'938'463'463'374'607'431'768'211'455 39 digits)
----------------
Mordante wrote:
> nilayvaish wrote:
> > I think the MSB is missing.
> What do you exactly mean with "the MSB is missing"?
2^64 = 18446744073709551616.  The most significant digit would be 1.


================
Comment at: libcxx/include/charconv:167
+    // There's always a bit set in the upper 64-bits.
+    auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
+    _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds");
----------------
ldionne wrote:
> Can you add a reference to the documentation for this trick?
+1.  I don't quite understand what we are trying to achieve here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128929/new/

https://reviews.llvm.org/D128929



More information about the libcxx-commits mailing list