about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2025-04-30 15:22:01 +0200
committerptitSeb <sebastien.chev@gmail.com>2025-04-30 15:22:01 +0200
commitab70523b39eacac818efb8f8bacaf4d515eb98de (patch)
tree81850dd7984fda485ac7f391d882b53cf7f824a3 /src
parentf0859e64620807e2eb0660aa7d73395ab7ce4ab5 (diff)
downloadbox64-ab70523b39eacac818efb8f8bacaf4d515eb98de.tar.gz
box64-ab70523b39eacac818efb8f8bacaf4d515eb98de.zip
[INTERP] Improve NAN handling on SQRTPS opcode
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64run660f.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/emu/x64run660f.c b/src/emu/x64run660f.c
index a55a7328..7232c0c5 100644
--- a/src/emu/x64run660f.c
+++ b/src/emu/x64run660f.c
@@ -1287,8 +1287,10 @@ uintptr_t Run660F(x64emu_t *emu, rex_t rex, uintptr_t addr)
         GETEX(0);

         GETGX;

         for (int i=0; i<2; ++i) {

-            if(EX->d[i]<0.0)        // on x86, default nan are negative

-                GX->d[i] = -NAN;    // but input NAN are not touched (so sqrt(+nan) -> +nan)

+            if(EX->d[i]<0.0)            // on x86, default nan are negative

+                GX->d[i] = -NAN;        // but input NAN are not touched (so sqrt(+nan) -> +nan)

+            else if(isnan(EX->d[i]))

+                GX->d[i] = EX->d[i];

             else

                 GX->d[i] = sqrt(EX->d[i]);

         }