! \brief Executes the operations: /, MOD, ** (POW), *. \param lhs pointer to the left hand side operand and result. \param operation \ref ngc_binary_op_t enum value. \param rhs pointer to the right hand side operand. \returns #Error::Ok enum value if processed without error, appropriate \ref Error enum value if not. */
| 101 | \returns #Error::Ok enum value if processed without error, appropriate \ref Error enum value if not. |
| 102 | */ |
| 103 | static Error execute_binary1(float& lhs, ngc_binary_op_t operation, const float& rhs) { |
| 104 | Error status = Error::Ok; |
| 105 | |
| 106 | switch (operation) { |
| 107 | case Binary_DividedBy: |
| 108 | if (rhs == 0.0f || rhs == -0.0f) |
| 109 | status = Error::ExpressionDivideByZero; // Attempt to divide by zero |
| 110 | else |
| 111 | lhs = lhs / rhs; |
| 112 | break; |
| 113 | |
| 114 | case Binary_Modulo: // always calculates a positive answer |
| 115 | lhs = fmodf(lhs, rhs); |
| 116 | if (lhs < 0.0f) |
| 117 | lhs = lhs + fabsf(rhs); |
| 118 | break; |
| 119 | |
| 120 | case Binary_Power: |
| 121 | if (lhs < 0.0f && floorf(rhs) != rhs) |
| 122 | status = Error::ExpressionInvalidArgument; // Attempt to raise negative value to non-integer power |
| 123 | else |
| 124 | lhs = powf(lhs, rhs); |
| 125 | break; |
| 126 | |
| 127 | case Binary_Times: |
| 128 | lhs = lhs * rhs; |
| 129 | break; |
| 130 | |
| 131 | default: |
| 132 | status = Error::ExpressionUnknownOp; |
| 133 | } |
| 134 | |
| 135 | if (status != Error::Ok) |
| 136 | report_param_error(status); |
| 137 | |
| 138 | return status; |
| 139 | } |
| 140 | |
| 141 | /*! \brief Executes the operations: +, -, AND, OR, XOR, EQ, NE, LT, LE, GT, GE |
| 142 | The RS274/NGC manual does not say what |
no test coverage detected