COMPUTE
Truncated
COBOL
JAVA
COMPUTE
Regular Java arithmetical expression OR multiply, add, subtract, divide
Syntax
< result > . assign ( < operand1 > < operator1 > < operand2 > < operator2 > < operand3 > ... )
< result > . assign ( < operator function > ( < operand1 > ( ) , < operand2 > ( ) ) )
Parameters
<result>
The variable to place the result of the computation in.
<operandN>
The operands to use in the computation.
<operatorN>
The operators to use in the computation. Must be one of +, -, * or /.
COBOL Operators
The COBOL operator ** for exponentiation is translated in Java into CalcPower(). Additions or
subtractions with 2 integers (either variables or literals) will be translated as ADD or SUBTRACT
respectively. See ADD or SUBTRACT.
Examples
COBOL
Java
COMPUTE X = A * B + W
locDef . x . assign ( locDef . a . getIntValue () * locDef . b . getIntValue () + locDef . w . getIntValue ());
COMPUTE C = B - A
locDef . c . assign ( subtract ( locDef . b . getIntValue (), locDef . a . getIntValue ()));
// OR
locDef . c . assign ( locDef . b . getIntValue () - locDef . a . getIntValue ());
Exponentiation
COBOL
JAVA
COMPUTE .... **
calcPower
Syntax
< result > . assign ( calcPower ( < operand1 > ( ) , < operand2 > ( ) ) )
Parameters
<result>
The variable to place the result of the exponential computation in.
<operandN>
The operands to use in the exponential computation.
Examples
COBOL
Java
COMPUTE A = W ** X .
locDef . a . assign ( calcPower ( locDef . w . getIntValue (), locDef . x . getIntValue ()));
Invert sign
COBOL
JAVA
COMPUTE .... * -1
invertSign
Syntax
< variable >. invertSign ( )
Parameters
<variable>
The variable which sign needs to be inverted.
COMPUTE
Using COMPUTE to change the sign of a single variable, will be translated to the InvertSign function.
Examples
COBOL
Java
COMPUTE A = A * -1 .
locDef . a . invertSign ();
COMPUTE Z = -1 * Z .
locDef . z . invertSign ();
Rounded
COBOL
JAVA
COMPUTE .... ROUNDED
round
Syntax
< result > . assign ( round (< result >, < operator function >(< operand1 > ( ), < operand2 > ( ) ) ) )
Parameters
<result>
The variable to place the result of the rounded computation in.
COBOL Operators
The COBOL operator ** for exponentiation is translated in Java into calcPower().
Examples
COBOL
Java
COMPUTE A ROUNDED = W / X .
locDef . a . assign ( round ( locDef . a , divide ( locDef . w . getIntValue (), locDef . x . getIntValue ())));
COMPUTE W ROUNDED = A / B ** C .
m_LocDef . W . Value = Round ( m_LocDef . W , m_LocDef . A . Value / CalcPower ( m_LocDef . B . Value , m_LocDef . C . Value ));