var.opBinary

var opBinary(string op)(const var rhs) if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%") const @safe

Binary arithmetic operators for var.

Supported operators: `+`, `-`, `*`, `/`, `%`

Type promotion rules:

  • If either operand is DOUBLE, FLOAT, or REAL, the result is DOUBLE.
  • If either operand is ULONG and the other is unsigned or fits, result is ULONG.
  • If either operand is LONG, result is LONG.
  • Otherwise, result is INT for smaller integer types.
  • For non-numeric types (NULL, STRING, ARRAY, OBJECT, CHAR, WCHAR, DCHAR, BOOL), the operation returns var.init (NULL).

    Parameters

    opThe binary operator (`"+"`, `"-"`, `"*"`, `"/"`, `"%"`).
    rhsThe right-hand side operand.

    Returns

    A new var containing the result of the operation, or var.init if the operation is not supported for the given types.

Notes: Integer division/modulo by zero returns var.init (NULL) instead of silently yielding 0.