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:
|
result |
Numeric result of the operation. |
|
expression |
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 |
|
sin() |
Evaluate sine |
|
cos() |
Evaluate cosine |
|
atan() |
Evaluate arc tangent |
|
exp() |
Exponential |
|
abs() |
Absolute value |
|
sqrt() |
Square root |
|
log10() |
Base 10 logarithm |
|
log() |
Base 10 logarithm |
|
ln() |
Base e (natural) logarithm |
The CALC() function produces these return codes:
|
101 |
One of the following: ARG 1 MISSING OR INVALID CHARACTER IN ARG 1 |
|
102 |
ARG 2 INVALID |
|
121 |
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 © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |