[libc-commits] [PATCH] D150399: [libc] add options to printf decimal floats

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu May 11 21:51:21 PDT 2023


lntue added inline comments.


================
Comment at: libc/src/__support/float_to_string.h:171
+  // calculation as above. Due to floating point imprecision it is only accurate
+  // for the first 50 digits, but it's much faster. This is ideal for embedded
+  // situations that want to avoid the table altogether, and are willing to
----------------
You could also mention that 50 digits is more than enough for the round trip `long double -> decimal string -> long double` to be correct, even when `long double` is quad precision (i.e. float128).


================
Comment at: libc/src/__support/float_to_string.h:193
+    fputil::DyadicFloat<INT_SIZE> fives = fputil::pow_n(FIVE_EXP_MINUS_NINE, i);
+    num = fputil::quick_mul(num, fives);
+  }
----------------
You can add a `mul_pow_2` method that simply adds the exponent field in-place for a DyadicFloat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150399



More information about the libc-commits mailing list