Skip to content

Commit

Permalink
Make division by 0 return NAN when output is a floating point type, n…
Browse files Browse the repository at this point in the history
…ot 0.

For now the division by zero warning is kept.

Fixed #240.
  • Loading branch information
divVerent committed Jan 5, 2025
1 parent 53b5b45 commit 0be808c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions prvm_execprogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ prvm_eval_t *src;
{
PRE_ERROR();
VM_Warning(prog, "Attempted division of %f by zero\n", OPA->_float);
OPC->_float = 0.0f;
OPC->_float = NAN;
}
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_BITAND_F):
Expand Down Expand Up @@ -895,9 +895,9 @@ prvm_eval_t *src;
{
PRE_ERROR();
VM_Warning(prog, "Attempted division of '%f %f %f' by zero\n", OPA->vector[0], OPA->vector[1], OPA->vector[2]);
OPC->vector[0] = 0.0f;
OPC->vector[1] = 0.0f;
OPC->vector[2] = 0.0f;
OPC->vector[0] = NAN;
OPC->vector[1] = NAN;
OPC->vector[2] = NAN;
}
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_DIV_I):
Expand All @@ -923,7 +923,7 @@ prvm_eval_t *src;
{
PRE_ERROR();
VM_Warning(prog, "Attempted division of %"PRVM_PRIi" by zero\n", OPA->_int);
OPC->_float = 0;
OPC->_float = NAN;
}
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_DIV_FI):
Expand All @@ -935,7 +935,7 @@ prvm_eval_t *src;
{
PRE_ERROR();
VM_Warning(prog, "Attempted division of %f by zero\n", OPA->_float);
OPC->_float = 0;
OPC->_float = NAN;
}
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_CONV_ITOF):
Expand Down

0 comments on commit 0be808c

Please sign in to comment.