summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu
diff options
context:
space:
mode:
author Matthew Daniels <108370479+gm-matthew@users.noreply.github.com>2025-03-21 16:40:22 +0000
committer GitHub <noreply@github.com>2025-03-21 17:40:22 +0100
commit53f391ff5e8bc14a4689cf15dc907d1a46b74b1f (patch)
tree474ce09ac1f59331f63860ec3ff488476f602537 /src/devices/cpu
parent760ae7030571b7ccb596dd52eeb867656525619e (diff)
v60: implement correct rounding mode when converting float to integer (#13506)
Diffstat (limited to 'src/devices/cpu')
-rw-r--r--src/devices/cpu/v60/op2.hxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/devices/cpu/v60/op2.hxx b/src/devices/cpu/v60/op2.hxx
index 9e5292d3f9b..9714a034027 100644
--- a/src/devices/cpu/v60/op2.hxx
+++ b/src/devices/cpu/v60/op2.hxx
@@ -71,7 +71,13 @@ uint32_t v60_device::opCVTSW()
// Convert to uint32_t
val = u2f(m_op1);
- m_modwritevalw = (uint32_t)(int64_t)val;
+ switch (TKCW & 7)
+ {
+ case 0: m_modwritevalw = (uint32_t)(int64_t)round(val); break;
+ case 1: m_modwritevalw = (uint32_t)(int64_t)floor(val); break;
+ case 2: m_modwritevalw = (uint32_t)(int64_t)ceil(val); break;
+ default: m_modwritevalw = (uint32_t)(int64_t)trunc(val); break;
+ }
_S = ((m_modwritevalw & 0x80000000) != 0);
_OV = (_S && val >= 0.0f) || (!_S && val <= -1.0f);