Skip to content

Commit da09f7d

Browse files
committed
cast x_abs to double
1 parent e43a97e commit da09f7d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

libc/src/math/generic/asinpif16.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@
2020

2121
namespace LIBC_NAMESPACE_DECL {
2222

23-
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
24-
static constexpr size_t N_ASINPIF16_EXCEPTS = 3;
25-
2623
LLVM_LIBC_FUNCTION(float16, asinpif16, (float16 x)) {
2724
using FPBits = fputil::FPBits<float16>;
2825

2926
FPBits xbits(x);
3027
bool is_neg = xbits.is_neg();
31-
float16 x_abs = xbits.abs().get_val();
28+
double x_abs = fputil::cast<double>(xbits.abs().get_val());
3229

3330
auto signed_result = [is_neg](auto r) -> auto { return is_neg ? -r : r; };
3431

35-
if (LIBC_UNLIKELY(x_abs > 1.0f16)) {
32+
if (LIBC_UNLIKELY(x_abs > 1.0)) {
3633
// aspinf16(NaN) = NaN
3734
if (xbits.is_nan()) {
3835
if (xbits.is_signaling_nan()) {
@@ -87,7 +84,7 @@ LLVM_LIBC_FUNCTION(float16, asinpif16, (float16 x)) {
8784
};
8885

8986
// if |x| <= 0.5:
90-
if (LIBC_UNLIKELY(x_abs <= 0.5f16)) {
87+
if (LIBC_UNLIKELY(x_abs <= 0.5)) {
9188
// Use polynomial approximation of asin(x)/pi in the range [0, 0.5]
9289
double result = asinpi_polyeval(fputil::cast<double>(x));
9390
return fputil::cast<float16>(result);
@@ -120,7 +117,7 @@ LLVM_LIBC_FUNCTION(float16, asinpif16, (float16 x)) {
120117
// = 0.5 - 0.5 * x
121118
// = multiply_add(-0.5, x, 0.5)
122119

123-
double u = fputil::multiply_add(-0.5, fputil::cast<double>(x_abs), 0.5);
120+
double u = fputil::multiply_add(-0.5, x_abs, 0.5);
124121
double asinpi_sqrt_u = asinpi_polyeval(fputil::sqrt<double>(u));
125122
double result = fputil::multiply_add(-2.0, asinpi_sqrt_u, 0.5);
126123

0 commit comments

Comments
 (0)