Why do I get “Invalid operand for unary operator” in an expression?

Docmosis may report “Invalid operand for unary operator” when a unary minus is applied directly to a data field.

For example:

<<{(-b + sqrt($d)) / (2*a)}>>

The problem is the "-b".

The solution is to rewrite the "negative sign" as an expression that uses the subtraction operation and two operands:

<<{(0-b + sqrt($d)) / (2*a)}>>

In this case, "0-b" is the same as "negative b" or "-b".

Or, where appropriate, rearrange the expression:

<<{(sqrt($d)-b) / (2*a)}>>

This does not mean that b cannot contain a negative value in your JSON data. A value such as "b": -3 is valid. The issue is specifically the use of the unary - operator directly on the field within the template expression.