1.Functional Description
1.1Purpose
This business function calculates the algebraic expression in a string and return a mathnumeric value
if the return code is SUCCESS, otherwise return error message ID.
1.2Setup Notes and Prerequisites
The Input string format:
May or may not contain blank(s)
May not contain character string other than arithmetic functions.
All arithmetic function characters must be in upper case,
Available arithmetic functions:
INTRound off to integer
SGNChange sign of value
SQRSquare root
**Exponent
LNNatural Logarithm
LOGLogarithm base 10
COSCosine
SINSine
TANTangent
ARCArc Tangent
1.3Special Logic
A.Delimiters:
The following delimiters are prioritized as:
2)'/'Division
3)'*'Multiplication
4)'-'Minus
5)'+'Addition
6)'('Left parentheses
2.Technical Specifications
2.4Processing
A.Parentheses:
Scan through input string for quick inspection on parentheses. Parenthesis must go
in pair and each left parenthesis must has a right parentheses. If the parentheses
is improperly place, skip all steps below and return ERROR status.
Scan through input string for inspection on characters. There should not be any character or string
other than function names that defined in section 1.2. If there is any invalid character or string,
skip all steps below and return ERROR status.
C.Evaluation:
Perform evaluation of delimiters in prioritized order as defined in section 1.3
2) Algebraic expression in the parentheses.
3) Algebraic expression string
D.Return:
If there is any error during evaluation, return ERROR status.
Else return SUCCESS status and result.
3. Examples
2+3-4*5/6 => 2+3-20/6 =>2+3-3.33333 = 1.66667
2+(3-4)*5 => 2-1*5 = -3
(2+(3-4)*5)**(8-6) => (2-1*5)**(8-6) => (-3)**2 = 9
(1+ABS(COS(3.1416)))/(2+1)-5 => (1+ABS(-1))/(2+1)-5
D0000500 - Algebraic Expression Calculate
Parameter Name | Data Item | Data Type | Req/Opt | I/O/Both |
---|---|---|---|---|
szAlgebraicExpressionString | CALCIT | char | NONE | NONE |
This field is used to store an algebraic expression string | ||||
mnCalculatingResult | MN29D9 | MATH_NUMERIC | NONE | NONE |
This is a generic field used as a work field in Everest. | ||||
cSuppressErrorMessage | EV01 | char | NONE | NONE |
An option that specifies the type of processing for an event. | ||||
szErrorMessageID | DTAI | char | NONE | NONE |
A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or
|
None |
None |