[libc-commits] [PATCH] D156813: [libc] Fix float to string conversion in 32-bit systems

Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 2 05:51:28 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG44bf4c8944f5: [libc] Fix float to string conversion in 32-bit systems (authored by Mikhail R. Gadelha <mikhail at igalia.com>).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156813

Files:
  libc/src/__support/float_to_string.h


Index: libc/src/__support/float_to_string.h
===================================================================
--- libc/src/__support/float_to_string.h
+++ libc/src/__support/float_to_string.h
@@ -387,15 +387,9 @@
                                        const int32_t shift_amount) {
   constexpr size_t MANT_INT_SIZE = sizeof(MantissaInt) * 8;
   cpp::UInt<MID_INT_SIZE + MANT_INT_SIZE> val(large);
-  // TODO: Find a better way to force __uint128_t to be UInt<128>
-  cpp::UInt<MANT_INT_SIZE> wide_mant(0);
-  wide_mant[0] = static_cast<size_t>(mantissa & (uint64_t(-1)));
-  wide_mant[1] = static_cast<size_t>(mantissa >> 64);
-  val = (val * wide_mant) >> shift_amount;
-
+  val = (val * mantissa) >> shift_amount;
   return static_cast<uint32_t>(
       val.div_uint32_times_pow_2(1000000000, 0).value());
-  // return fast_uint_mod_1e9(val);
 }
 
 } // namespace internal


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156813.546427.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230802/223ad77d/attachment.bin>


More information about the libc-commits mailing list