[libc-commits] [libc] [libc] Alternative algorithm for decimal FP printf (PR #123643)
via libc-commits
libc-commits at lists.llvm.org
Mon Jan 27 07:50:34 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 57466db7a459ce285f053ecac3c309f49f2cce6a 516c28c336c2167c922b5c5aa00d001ed93bd1e5 --extensions h,cpp -- libc/src/stdio/printf_core/float_dec_converter_limited.h libc/src/__support/CPP/algorithm.h libc/src/__support/FPUtil/dyadic_float.h libc/src/__support/big_int.h libc/src/__support/sign.h libc/src/stdio/printf_core/converter_atlas.h libc/test/src/stdio/sprintf_test.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index 855aed599f..4f3d7f195b 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -42,10 +42,9 @@ template <size_t Bits>
LIBC_INLINE constexpr int
rounding_direction(const LIBC_NAMESPACE::UInt<Bits> &value, size_t rshift,
Sign logical_sign) {
- if (rshift == 0 ||
- (rshift < Bits && (value << (Bits - rshift)) == 0) ||
+ if (rshift == 0 || (rshift < Bits && (value << (Bits - rshift)) == 0) ||
(rshift >= Bits && value == 0))
- return 0; // exact
+ return 0; // exact
switch (quick_get_round()) {
case FE_TONEAREST:
@@ -53,7 +52,9 @@ rounding_direction(const LIBC_NAMESPACE::UInt<Bits> &value, size_t rshift,
// We round up, unless the value is an exact halfway case and
// the bit that will end up in the units place is 0, in which
// case tie-break-to-even says round down.
- return value.get_bit(rshift) != 0 || (value << (Bits - rshift + 1)) != 0 ? +1 : -1;
+ return value.get_bit(rshift) != 0 || (value << (Bits - rshift + 1)) != 0
+ ? +1
+ : -1;
} else {
return -1;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/123643
More information about the libc-commits
mailing list