summaryrefslogtreecommitdiff
path: root/libc/src/math/generic/cbrtf.cpp
AgeCommit message (Collapse)Author
2025-08-08[libc][math] Refactor cbrtf implementation to header-only in ↵Muhammad Bassiouni
src/__support/math folder. (#151846) Part of #147386 in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-03-20[libc][math] Add missing parenthesis in sollya command (#132298)Krishna Pandey
This PR adds the missing opening parenthesis for sollya command comment in `libc/src/math/generic/cbrtf.cpp#L28`. Signed-off-by: krishna2803 <kpandey81930@gmail.com>
2024-10-26[libc][math] Add tests and fix some issues with FTZ/DAZ modes. (#113744)lntue
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-07-08[libc][math] Implement cbrtf function correctly rounded to all rounding ↵lntue
modes. (#97936) Fixes https://github.com/llvm/llvm-project/issues/92874 Algorithm: Let `x = (-1)^s * 2^e * (1 + m)`. - Step 1: Range reduction: reduce the exponent with: ``` y = cbrt(x) = (-1)^s * 2^(floor(e/3)) * 2^((e % 3)/3) * (1 + m)^(1/3) ``` - Step 2: Use the first 4 bit fractional bits of `m` to look up for a degree-7 polynomial approximation to: ``` (1 + m)^(1/3) ~ 1 + m * P(m). ``` - Step 3: Perform the multiplication: ``` 2^((e % 3)/3) * (1 + m)^(1/3). ``` - Step 4: Check for exact cases to prevent rounding and clear `FE_INEXACT` floating point exception. - Step 5: Combine with the exponent and sign before converting down to `float` and return.