[libc-commits] [libc] [llvm] [libc][math][c23] Add atan2f16 function (PR #183531)
Xinlong Chen via libc-commits
libc-commits at lists.llvm.org
Thu Feb 26 18:47:35 PST 2026
Xinlong-Chen wrote:
I write a program to compare `atan2f` with `atan2f16` using same input:
```
float16 x16 = static_cast<float16>(x);
float16 y16 = static_cast<float16>(y);
float r_ref = LIBC_NAMESPACE::atan2f(static_cast<float>(y16),
static_cast<float>(x16));
float16 r16 = LIBC_NAMESPACE::atan2f16(y16, x16);
float r16_as_float = static_cast<float>(r16);
```
test range is [-2, 2], and I split it into a 20,000 * 20,000 grid. The results are as follows:
```
Same-input grid: 20000 x 20000, both use (x16,y16), tolerance = 1.00e-03
Exact same: 47304
Within tolerance: 400000000
Outside tol: 0
Max abs diff: 0.000976800919 (at x16=-1.98925781, y16=-1.64648438)
```
This roughly matches the data precision of `f16`.
https://github.com/llvm/llvm-project/pull/183531
More information about the libc-commits
mailing list