From 5da14eaaf56d237d6a2999ebb3c3bfa7a2207d74 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 6 Jan 2025 18:49:10 -0500 Subject: [PATCH] DIV_VF: make it slightly more correct (but slower). We really should divide three times separately than compute the reciprocal and multiply by that three times. The latter allows two roundoff errors, the former only one. --- prvm_execprogram.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prvm_execprogram.h b/prvm_execprogram.h index 2eb0c298..b26c6db2 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -886,10 +886,10 @@ prvm_eval_t *src; HANDLE_OPCODE(OP_DIV_VF): if( OPB->_float != 0.0f ) { - float temp = 1.0f / OPB->_float; - OPC->vector[0] = temp * OPA->vector[0]; - OPC->vector[1] = temp * OPA->vector[1]; - OPC->vector[2] = temp * OPA->vector[2]; + tempfloat = OPB->_float; + OPC->vector[0] = OPA->vector[0] / tempfloat; + OPC->vector[1] = OPA->vector[1] / tempfloat; + OPC->vector[2] = OPA->vector[2] / tempfloat; } else { -- 2.39.5