5.3.1. Arithmetic Term

[Tip]Description

An arithmetic term is an ASM term that evaluates to an arbitrary value (string, integer, float, boolean, model element).

[Important]Syntax
ArithmeticTermAST ::= MultArithmeticTermAST 
                    | ArithmeticTermAST + MultArithmeticTermAST
                    | ArithmeticTermAST - MultArithmeticTermAST

An arithmetic term is composed of multiplicative arithmetic terms with an arithmetic add + or subtract - operator.

[Note]Semantics

The arithmetic term evaluation is defined in Table 2.6, “Add (+) operator ”, and Table 2.7, “Subtract (-) operator ”, which shows the type of the output with respect to the types of each operand.

The interpretation of operators + and - is the classical in case of integers and doubles (i.e. addition and subtraction).

Applying the + operator to two Strings means concatenation.

If any operation has an undef value among its operands, the result is always undef, except when it is added to a string; in this case the undef value is converted to the 'undef' string.

Table 2.6. Add (+) operator

 UndefBooleanStringIntegerDoubleModelElementMultiplicity
UndefUndefUndefStringUndefUndefUndefUndef
BooleanUndef String    
StringStringStringStringStringStringStringString
IntegerUndef StringIntDouble  
DoubleUndef StringDoubleDouble  
ModelElementUndef String    
MultiplicityUndef String    


Table 2.7. Subtract (-) operator

 UndefBooleanStringIntegerDoubleModelElementMultiplicity
UndefUndefUndefUndefUndefUndefUndefUndef
BooleanUndef      
StringUndef      
IntegerUndef  IntDouble  
DoubleUndef  DoubleDouble  
ModelElementUndef      
MultiplicityUndef      


[Warning]Warning

Note that the evaluation rules of arithmetic operators changed in the new release to be compliant with its use in Java.

Remark.  There is no implicit type casting on the input of the operands; conversion operators have to be used if casting is required.

Defined In:  term

Used By:  base logical term