Use the CALC() function to evaluate a complex numerical expression and return the results.
The CALC() function has this syntax:
result = CALC(expression,[decimal])
The CALC() function takes these arguments:
Numeric result of the operation.
Mathematical expression to be evaluated. Numbers can be up to six significant digits, containing a decimal point and leading plus sign or leading minus sign if needed. Blanks are ignored. The operators you can use are shown in the following section.
Because CALC() uses true floating-point arithmetic, values can be imprecise. Very large and very small numbers include a scaling factor (power of 10), and return values in the following form:
1.23456 * 10 ** 25
decimal
Number of digits to the right of the decimal point.
Default: All significant digits appear, but trailing zeros are omitted.
These operators can be used within the expression:
Plus
Minus
Raise to a power
Multiply
Divide
Start priority grouping
End priority grouping
Evaluate sine
Evaluate cosine
Evaluate arc tangent
Exponential
Absolute value
Square root
Base 10 logarithm
Base 10 logarithm
Base e (natural) logarithm
The CALC() function produces these return codes:
One of the following:
ARG 1 MISSING OR INVALID
CHARACTER IN ARG 1
ARG 2 INVALID
One of the following:
EXPECTED OPERATOR MISSING
TOO MANY NUMERIC FIELDS
OPERATOR FOLLOWS OPERATOR
INVALID OPERATOR
NUMBER FOLLOWS RIGHT PARENTHESIS
UNBALANCED PARENTHESES
OVERFLOW OR UNDERFLOW
EXPRESSION TOO COMPLEX
ERROR DURING SIN/COS EVALUATION
ERROR DURING EXP EVALUATION
ERROR DURING LOG EVALUATION
ERROR DURING SQRT EVALUATION
RESULT TOO LARGE
DIVISION BY ZERO
Example
calc('1+1') == '2'
calc('(1+2)*5') == '15' /* Not 11 */
calc('abs(-9)') == '9'
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |