57 const int exponent = ((cast.as_int & 0x7f800000) >> 23) - 127;
60 cast.as_uint = (cast.as_uint & ~0xff800000) | 0x3f800000;
61 const float x_norm = cast.as_float;
65 const float x = x_norm * (float)M_SQRT1_2 - 1.0f;
69 9.99976591940035e-01f +
70 x * (-3.32901212909283e-01f +
71 x * (2.24361110929912e-01f +
72 x * (-1.88913279594895e-01f + x * 1.28384036492344e-01f)));
75 int exponent_new = exponent;
76 if (exponent_new < 0) exponent_new -= 2;
77 exponent_new = -exponent_new / 3;
78 const int exponent_rem = exponent + 3 * exponent_new;
79 cast.as_uint = (exponent_new + 127) << 23;
80 static const float scale[3] = {8.90898718140339e-01f, 7.07106781186548e-01f,
81 5.61231024154687e-01f};
82 const float exponent_scale = cast.as_float * scale[exponent_rem];
85 res = copysignf(res * exponent_scale, x_in);
88 res *= (1.0f / 3.0f) * (4.0f - x_in * res * res * res);