Introduction
Today we will help you to understand and resolve Error G0064: Operand Missing
. We will answer the questions:
- What is an operand?
- How do common mathematical and non-mathematical operators interact with operands?
- What are common causes of operand missing errors?
What is an operand?
An operand is a symbol that an operator operates on. For example, in the line below:
X = 4 + 5;
The plus sign is the operator and both 4
and 5
are operands.
Mathematical and Logical Operators
When you think of operators, the mathematical and logical operators tend to come to mind first. For example, operators like those shown in the table below.
Mathematical and Logical Operators | ||
---|---|---|
Operator | Purpose | |
+ | Addition. | |
* , .* | Multiplication and element-by-element multiplication. | |
^ | Exponentiation. | |
== , .== | Logical equality and element-by-element logical equality. | |
!== , .!== | Logical not equal and element-by-element logical not equal | |
> , .> | Greater than and element-by-element greater. |
Operand Missing Errors with Mathematical and Logical Operators
Missing operand errors that occur with mathematical operators tend to be simple to understand and fix, so we will only show one example.
Example 1
Correct statement | Incorrect statement |
---|---|
|
|
The element-by-element multiplication operator requires two operands, one on the right-hand side and one on the left. | The code snippet is missing the left side operand and will return the operand missing error. |
Non-mathematical Operators
Unlike the logical and mathematical operators, many of the “other” operators are not commonly noticed or considered.
Non-mathematical Operators | ||
---|---|---|
Operator | Description | Purpose |
, | Commma | Separates items in lists. |
| Space | Separates items in print statements and indices inside index brackets. |
. | Period | Signifies all rows or all columns inside of index brackets. |
: | Colon | Creates a continuous series of indices inside of index brackets. |
Comma Operator Examples
Comma Operator Example One
Correct statement | Incorrect statement |
---|---|
|
|
The comma operator is used to separate the operands 4 and 2. | The comma operator is used, but there are no operands for the comma operator to separate. |
Comma Operator Example Two
Correct statement | Incorrect statement |
---|---|
|
|
The comma operator separates the index operands 6 and 1. | The comma operator is used, but there is not a column index on the right side of the comma. |
Colon Operator Example
Operand missing statements with the colon operator will look like the previous comma operator errors.
Correct statement | Incorrect statement |
---|---|
|
|
The colon operator separates the index operands 3 and 5. | The colon operator is used, but there is not a column index on the right side of the colon. |
Print Statements and the Space Operator
The usage of space operator is probably the most likely “operand missing” error to trip up new GAUSS users.
The print
statement takes a space-separated list of items to print. For example:
print 4 5 6;
will return:
4.0000 5.0000 6.0000
Similarly, we can print the same data with variables like this:
A = 4;
B = 5;
print A B 6;
And GAUSS will again return:
4.0000 5.0000 6.0000
So far this is quite simple and something you may have done without a thought. However, adding an operator can cause a problem. For example, because the print
statement uses the space operator to separate the items to print, the statement:
print A + B;
is interpreted by GAUSS as the following instructions:
Print the value of A.
Print the value of +.
Print the value of B.
Therefore, when GAUSS gets to the +
sign, it does not see enough operands, because it has already been told to print A.
You can resolve this by removing the space operator between A
, +
and B
, or by adding parentheses around the statement.
A = 4;
B = 5;
// Option 1: Add parentheses
// around the sum of A and B
print (A + B);
// Option 2: Remove space operator
// to print the sum of A and B
print A+B;
The parentheses (or dropped spaces) only need to be around the operator. The table below shows a few variations and the resulting printed output.
Statement | Output |
---|---|
| 9.0000 6.0000 |
| 54.0000 |
| 1.5000 |
| 4.0000 30.0000 |
Conclusion
Congratulations! In today's blog, you have learned:
- What mathematical, logical, and non-mathematical operands are in GAUSS.
- Common causes of the
G0064: Operand Missing
error.
Further reading
- Understanding Errors | G0025 : Undefined symbol
- Understanding Errors: G0058 Index out-of-Range
- GAUSS Basics 6: Logical and relational operators