Operators in DM and C++ - Practical Electron Microscopy and Database - - An Online Book - |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Microanalysis | EM Book http://www.globalsino.com/EM/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
================================================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In DM, an expression can be a constant, variable, function call, or be composed of one or more operations. An expression, composed of two or more operations, is called a compound expression. C++ and thus DM has many built-in operators. Operators tell the compiler to
perform specific mathematical or logical manipulations. The operators in C++ can be categorized by: Table 1136a. Arithmetic operators allowed in C++ and DM.
The increment and decrement in DM and C++ are two operators not found in some other computer languages. In programs, both the increment and decrement operators can either precede (prefix, ++x) or follow
(postfix, x++) the operand. In some cases, there is no difference whether the increment is applied as
a prefix or a postfix. However, when an increment or decrement
operator precedes its operand (e.g. x), the corresponding operation will be performed prior
to obtaining the operand’s value for use by the rest of the expression. If the operator
ii) Equality, relational and logical. Relational refers to the relationships that values can have with one another, while logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, thus they often work with the logical operators. Table 1136c lists the equality, relational and logical operators allowed in C++ and DM. Table 1136c. Equality, relational and logical operators allowed in C++ and DM.
The logical operators are used to support the basic logical operations logical AND, OR, and NOT, according to the following truth in Table 1136d.
An example of logical OR operations is DM script. The result of the program is shown in Table 1136e. In this script, each digit performs an OR operation.
An example of logical AND operations is DM script. The result of the program is shown in Table 1136f. In this script, each digit performs an AND operation.
An example of logical NOT operations is DM script. In this script, each digit performs an NOT operation as well. C++ does not contain a built-in exclusive-OR (XOR) logical operator, but it can be easily constructed as shown in Table 1136g. In this case, the XOR operation produces a true result when one, and only one, operand
is true. For instance, the function of the following XOR
operation is constructed by using the && and || operators in DM application with output "1":
iii) Bitwise operators. Such operators act on individual bits of a number in binary representation. The expressions are cast as 32-bit integer values. Table 1136h. Bit-wise comparison operators in C++ and DM.
As discussed above, in DM and C++, logical XOR operation can be performed by "(a||b) &&!(a && b)"; however, in DM, XOR is simplified by "^" as shown in Table 1136h (e.g. DM script). Table 1136i. Results of a DM script of a logical XOR operation by following the rule in Table 1136g.
iv) Special operators for particular tasks.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
================================================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||