The most basic calculation expressions make use of constants, variables and operators. Suppose that A, B and C are variables that have values currently assigned to them. We can then use them with constants and operators to form new values that can then be assigned to other variables.
An example of a calculation expression is:
D=(A+B)*C
This expression looks like an equation. It makes use of the addition "+" operator, the multiplication "*" operator, the grouping "()" operator and the assignment "=" operator. When they are combined as shown they will calculate the value that you would expect and assign the result to a variable named D.
The above expression does not indicate the data types that were assigned to A, B and C before the computation. You cannot tell from the expression whether they are bytes, integers, long integers, floating point, complex or even if they are numbers at all. In fact, they need not all be of the same type, and often are not. They can be of any mixture of types for which the operations make sense and for which the operations are supported by the programming system. This is a very useful feature of IDL because it enables a fluent expression of the programmers intent using a conceptual form that is consistent and meaningful to people. But, like anything that is powerful and useful, you need to be aware of how it works to avoid having the power misdirected.
In IDL the data type of a variable is determined at the time that a value is assigned to it. The type may be changed if a new assignment is made using a different data type.
Examples
| a=10 | Assign the integer value 10 to the variable a. |
| b=3.4 | Assign the floating point value 3.4 to the variable b. |
| c=2*a+4 | Calculate the integer value 24 and assign the value to c |
| a=3*a+c | Calculate the integer value 54 and assign the value to a |
| d=a+2*b | Calculate the floating point value 16.8 and assign the value to d |
The expressions that can be written are determined by the operators and the operator hierarchy.