msvcrt: Make the tanhf function NAN preserving.
Signed-off-by: Martin Storsjo <martin@martin.st> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4fd9daea4a
commit
e93e246719
|
@ -1881,21 +1881,24 @@ float CDECL tanf( float x )
|
||||||
float CDECL tanhf( float x )
|
float CDECL tanhf( float x )
|
||||||
{
|
{
|
||||||
UINT32 ui = *(UINT32*)&x;
|
UINT32 ui = *(UINT32*)&x;
|
||||||
int sign;
|
UINT32 sign = ui & 0x80000000;
|
||||||
float t;
|
float t;
|
||||||
|
|
||||||
/* x = |x| */
|
/* x = |x| */
|
||||||
sign = ui >> 31;
|
|
||||||
ui &= 0x7fffffff;
|
ui &= 0x7fffffff;
|
||||||
x = *(float*)&ui;
|
x = *(float*)&ui;
|
||||||
|
|
||||||
if (ui > 0x3f0c9f54) {
|
if (ui > 0x3f0c9f54) {
|
||||||
/* |x| > log(3)/2 ~= 0.5493 or nan */
|
/* |x| > log(3)/2 ~= 0.5493 or nan */
|
||||||
if (ui > 0x41200000) {
|
if (ui > 0x41200000) {
|
||||||
|
if (ui > 0x7f800000) {
|
||||||
|
*(UINT32*)&x = ui | sign | 0x400000;
|
||||||
#if _MSVCR_VER < 140
|
#if _MSVCR_VER < 140
|
||||||
if (isnan(x))
|
|
||||||
return math_error(_DOMAIN, "tanhf", x, 0, x);
|
return math_error(_DOMAIN, "tanhf", x, 0, x);
|
||||||
|
#else
|
||||||
|
return x;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
/* |x| > 10 */
|
/* |x| > 10 */
|
||||||
fp_barrierf(x + 0x1p120f);
|
fp_barrierf(x + 0x1p120f);
|
||||||
t = 1 + 0 / x;
|
t = 1 + 0 / x;
|
||||||
|
|
Loading…
Reference in New Issue