From c997255367e56918bf06277a40dfa53edb925990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Tue, 29 Nov 2022 15:34:51 +0100 Subject: [PATCH] The divide operator now returns infinity when the numerator is infinity, and raises "Division by zero" error only if the numerator is zero. [INTERPRETER] * NEW: The divide operator now returns infinity when the numerator is infinity, and raises "Division by zero" error only if the numerator is zero. --- main/gbx/gbx_exec_loop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/gbx/gbx_exec_loop.c b/main/gbx/gbx_exec_loop.c index d1666bf5a..f9f39e813 100644 --- a/main/gbx/gbx_exec_loop.c +++ b/main/gbx/gbx_exec_loop.c @@ -2187,7 +2187,7 @@ _DIV_INTEGER: VALUE_conv_float(&SP[-1]); VALUE_conv_float(SP); SP[-1]._float.value /= SP->_float.value; - if (!isfinite(SP[-1]._float.value)) + if (!isfinite(SP[-1]._float.value) && SP->_float.value == 0) THROW(E_ZERO); goto _NEXT; @@ -2195,7 +2195,7 @@ _DIV_FLOAT: SP--; SP[-1]._float.value /= SP->_float.value; - if (!isfinite(SP[-1]._float.value)) + if (!isfinite(SP[-1]._float.value) && SP->_float.value == 0) THROW(E_ZERO); goto _NEXT; @@ -3473,7 +3473,7 @@ __FLOAT: __FLOAT_NC: P1->_float.value /= P2->_float.value; - if (isfinite(P1->_float.value)) + if (isfinite(P1->_float.value) || P2->_float.value) { SP--; return; @@ -3489,7 +3489,7 @@ __SINGLE: __SINGLE_NC: P1->_single.value /= P2->_single.value; - if (isfinite(P1->_single.value)) + if (isfinite(P1->_single.value) || P2->_single.value) { SP--; return;