[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kjs
From:       Christian Ehrlicher <Ch.Ehrlicher () gmx ! de>
Date:       2006-08-15 18:01:33
Message-ID: 1155664893.874442.3093.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 573320 by chehrlic:

use inline assembly for signbit (more or less copied from mingw) - maybe we should \
add this function to kdewin32 library...

CCMAIL: kde-windows@kde.org

 M  +11 -17    math_object.cpp  


--- trunk/KDE/kdelibs/kjs/math_object.cpp #573319:573320
@@ -30,25 +30,19 @@
 #if COMPILER(MSVC)
 
 #include <float.h>
-static int signbit(double d)
+#ifndef __FP_SIGNBIT
+# define __FP_SIGNBIT  0x0200
+#endif
+static __inline int signbit(double x)
 {
-    // FIXME: Not sure if this is exactly right.
-    switch (_fpclass(d)) {
-        case _FPCLASS_NINF:
-        case _FPCLASS_NN:
-        case _FPCLASS_ND:
-        case _FPCLASS_NZ:
-            // It's one of wacky negatives, report as negative.
-            return 1;
-        case _FPCLASS_PINF:
-        case _FPCLASS_PN:
-        case _FPCLASS_PD:
-        case _FPCLASS_PZ:
-            // It's one of wacky positives, report as positive.
-            return 0;
-        default:
-            return d < 0;
+    unsigned short sw;
+    __asm {
+        fld x
+        fxam
+        fstsw sw
+        fstp st
     }
+    return sw & __FP_SIGNBIT;
 }
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic