Alexandre Julliard : msvcrt: Reimplement _isnan().

Alexandre Julliard julliard at winehq.org
Mon Nov 16 15:28:57 CST 2020


Module: wine
Branch: master
Commit: d6476e0097948107088df9d73904c0be1c70d510
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d6476e0097948107088df9d73904c0be1c70d510

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Nov 16 12:18:03 2020 +0100

msvcrt: Reimplement _isnan().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/math.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 94a20e663fe..4b33630b438 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -242,12 +242,10 @@ int CDECL MSVCRT__finitef( float num )
 /*********************************************************************
  *      _isnanf (MSVCRT.@)
  */
-INT CDECL MSVCRT__isnanf( float num )
+int CDECL MSVCRT__isnanf( float num )
 {
-    /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
-     * Do the same, as the result may be used in calculations
-     */
-    return isnan(num) != 0;
+    union { float f; UINT32 i; } u = { num };
+    return (u.i & 0x7fffffff) > 0x7f800000;
 }
 
 /*********************************************************************
@@ -2234,12 +2232,10 @@ int CDECL MSVCRT_fesetenv(const MSVCRT_fenv_t *env)
 /*********************************************************************
  *		_isnan (MSVCRT.@)
  */
-INT CDECL MSVCRT__isnan(double num)
+int CDECL MSVCRT__isnan(double num)
 {
-  /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
-   * Do the same, as the result may be used in calculations
-   */
-  return isnan(num) != 0;
+    union { double f; UINT64 i; } u = { num };
+    return (u.i & ~0ull >> 1) > 0x7ffull << 52;
 }
 
 /*********************************************************************




More information about the wine-cvs mailing list