[libc-commits] [libc] [libc][math][c23] Add tanf16 function (PR #121018)
via libc-commits
libc-commits at lists.llvm.org
Mon Dec 30 11:00:45 PST 2024
================
@@ -63,10 +63,11 @@ LIBC_INLINE int32_t range_reduction_sincospif16(float x, float &y) {
// further intermediate computation.
LIBC_INLINE int32_t range_reduction_sincosf16(float x, float &y) {
double prod = x * 0x1.45f306dc9c883p3;
- double kf = fputil::nearest_integer(prod);
- y = static_cast<float>(prod - kf);
+ double kd = fputil::nearest_integer(prod);
- return static_cast<int32_t>(kf);
+ y = static_cast<float>(prod - kd);
+
+ return static_cast<int32_t>(kd);
}
----------------
overmighty wrote:
Since you're already fixing a minor naming issue here, could you also introduce a variable for 32/pi instead of copy-pasting it in the comment above and explaining it there? I think something like this would be more readable:
```cpp
LIBC_INLINE int32_t range_reduction_sincosf16(float x, float &y) {
// Generated by Sollya with:
// > D(32/pi);
constexpr double THIRTYTWO_OVER_PI = 0x1.45f306dc9c883p+3;
double prod = x * THIRTYTWO_OVER_PI;
double kd = fputil::nearest_integer(prod);
y = static_cast<float>(prod - kd);
return static_cast<int32_t>(kd);
}
```
https://github.com/llvm/llvm-project/pull/121018
More information about the libc-commits
mailing list