msvcrt: Improve asinf compatibility with native ucrtbase.
It reduces number of different asinf results from 5413834 to 639464. Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
eca796bf75
commit
0b8db61271
|
@ -356,23 +356,25 @@ float CDECL acosf( float x )
|
||||||
static float asinf_R(float z)
|
static float asinf_R(float z)
|
||||||
{
|
{
|
||||||
/* coefficients for R(x^2) */
|
/* coefficients for R(x^2) */
|
||||||
static const float pS0 = 1.6666586697e-01,
|
static const float p1 = 1.66666672e-01,
|
||||||
pS1 = -4.2743422091e-02,
|
p2 = -5.11644611e-02,
|
||||||
pS2 = -8.6563630030e-03,
|
p3 = -1.21124933e-02,
|
||||||
qS1 = -7.0662963390e-01;
|
p4 = -3.58742251e-03,
|
||||||
|
q1 = -7.56982703e-01;
|
||||||
|
|
||||||
float p, q;
|
float p, q;
|
||||||
p = z * (pS0 + z * (pS1 + z * pS2));
|
p = z * (p1 + z * (p2 + z * (p3 + z * p4)));
|
||||||
q = 1.0f + z * qS1;
|
q = 1.0f + z * q1;
|
||||||
return p / q;
|
return p / q;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CDECL asinf( float x )
|
float CDECL asinf( float x )
|
||||||
{
|
{
|
||||||
static const double pio2 = 1.570796326794896558e+00;
|
static const double pio2 = 1.570796326794896558e+00;
|
||||||
|
static const float pio4_hi = 0.785398125648;
|
||||||
|
static const float pio2_lo = 7.54978941586e-08;
|
||||||
|
|
||||||
double s;
|
float s, z, f, c;
|
||||||
float z;
|
|
||||||
unsigned int hx, ix;
|
unsigned int hx, ix;
|
||||||
|
|
||||||
hx = *(unsigned int*)&x;
|
hx = *(unsigned int*)&x;
|
||||||
|
@ -391,8 +393,11 @@ float CDECL asinf( float x )
|
||||||
}
|
}
|
||||||
/* 1 > |x| >= 0.5 */
|
/* 1 > |x| >= 0.5 */
|
||||||
z = (1 - fabsf(x)) * 0.5f;
|
z = (1 - fabsf(x)) * 0.5f;
|
||||||
s = sqrt(z);
|
s = sqrtf(z);
|
||||||
x = pio2 - 2 * (s + s * asinf_R(z));
|
/* f+c = sqrt(z) */
|
||||||
|
*(unsigned int*)&f = *(unsigned int*)&s & 0xffff0000;
|
||||||
|
c = (z - f * f) / (s + f);
|
||||||
|
x = pio4_hi - (2 * s * asinf_R(z) - (pio2_lo - 2 * c) - (pio4_hi - 2 * f));
|
||||||
if (hx >> 31)
|
if (hx >> 31)
|
||||||
return -x;
|
return -x;
|
||||||
return x;
|
return x;
|
||||||
|
|
Loading…
Reference in New Issue