[libc-commits] [libc] [libc][math] Add Generic Comparison Operations for floating point types (PR #144983)
via libc-commits
libc-commits at lists.llvm.org
Fri Jul 11 11:44:40 PDT 2025
================
@@ -245,22 +246,23 @@ template <size_t Bits> struct DyadicFloat {
StorageType result =
FPBits::create_value(sign, out_biased_exp, out_mantissa).uintval();
- switch (quick_get_round()) {
- case FE_TONEAREST:
- if (round && (lsb || sticky))
- ++result;
- break;
- case FE_DOWNWARD:
- if (sign.is_neg() && (round || sticky))
- ++result;
- break;
- case FE_UPWARD:
- if (sign.is_pos() && (round || sticky))
- ++result;
- break;
- default:
- break;
- }
+ if constexpr (!cpp::is_constant_evaluated())
+ switch (quick_get_round()) {
----------------
overmighty wrote:
We always need to round, it's just that in `constexpr` contexts we use `FE_TONEAREST` as rounding mode.
```suggestion
int rounding_mode = FE_TONEAREST;
if constexpr (!cpp::is_constant_evaluated())
rounding_mode = quick_get_round();
switch (rounding_mode) {
```
https://github.com/llvm/llvm-project/pull/144983
More information about the libc-commits
mailing list