[libc-commits] [PATCH] D140042: [libc] add exponent format to printf

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Dec 21 13:43:04 PST 2022


sivachandra added a comment.

Mostly LGTM with a question inline.



================
Comment at: libc/src/stdio/printf_core/float_dec_converter.h:190
+  cpp::string_view exp_str(int exponent, cpp::span<char> exp_buffer) {
+    int positive_exponent = exponent < 0 ? -exponent : exponent;
+    char exp_sign = exponent < 0 ? '-' : '+';
----------------
Is `-exponent` guaranteed to not overflow here? If not, then may be you should just let `IntegerToString` handle the sign for negative numbers,  but add a `+` if `exponent` is non-negative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140042



More information about the libc-commits mailing list