[libc-commits] [libc] [llvm] [libc][math][c23] Add {, u}fromfp{, x}{, f, l, f128} functions (PR #86003)
via libc-commits
libc-commits at lists.llvm.org
Thu Mar 21 08:03:13 PDT 2024
- Previous message: [libc-commits] [libc] [llvm] [libc][math][c23] Add {, u}fromfp{, x}{, f, l, f128} functions (PR #86003)
- Next message: [libc-commits] [libc] [llvm] [libc][math][c23] Add {, u}fromfp{, x}{, f, l, f128} functions (PR #86003)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
================
@@ -151,28 +151,30 @@ LIBC_INLINE T round_using_current_rounding_mode(T x) {
bool is_neg = bits.is_neg();
int exponent = bits.get_exponent();
- int rounding_mode = quick_get_round();
// If the exponent is greater than the most negative mantissa
// exponent, then x is already an integer.
if (exponent >= static_cast<int>(FPBits<T>::FRACTION_LEN))
return x;
if (exponent <= -1) {
- switch (rounding_mode) {
- case FE_DOWNWARD:
+ switch (rnd) {
+ case FP_INT_DOWNWARD:
return is_neg ? T(-1.0) : T(0.0);
- case FE_UPWARD:
+ case FP_INT_UPWARD:
return is_neg ? T(-0.0) : T(1.0);
- case FE_TOWARDZERO:
+ case FP_INT_TOWARDZERO:
return is_neg ? T(-0.0) : T(0.0);
- case FE_TONEAREST:
+ case FP_INT_TONEARESTFROMZERO:
+ if (exponent < -1)
+ return is_neg ? T(-0.0) : T(0.0); // abs(x) < 0.5
+ return is_neg ? T(-1.0) : T(1.0); // abs(x) >= 0.5
+ case FP_INT_TONEAREST:
+ default:
----------------
lntue wrote:
Probably at https://libc.llvm.org/dev/undefined_behavior.html (file location: `docs/dev/undefined_behavior.rst`)
https://github.com/llvm/llvm-project/pull/86003
- Previous message: [libc-commits] [libc] [llvm] [libc][math][c23] Add {, u}fromfp{, x}{, f, l, f128} functions (PR #86003)
- Next message: [libc-commits] [libc] [llvm] [libc][math][c23] Add {, u}fromfp{, x}{, f, l, f128} functions (PR #86003)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the libc-commits
mailing list