Arithmetical operations
The following types of arithmetical operations are defined in 1C:Enterprise script:
addition |
(Op1 + Op2) |
subtraction |
(Op1 - Op2) |
multiplication |
(Op1 * Op2) |
division |
(Op1 / Op2) |
residue of division |
(Op1 % Op2) |
unary minus |
(-Op1) |
Arithmetical operations have one or two operands, which determine operation semantics. Semantics of an operation depend on the first operand. If the second operand type does not match the required one, the value is converted into the required type in compliance with the type conversion rules. If the type of the first operand does not match any of the valid types, depending on situation, types can be converted or a runtime error can occur.
Addition is defined for the following operand types: |
Number+Number, Date+Number (the number of seconds is added to the date) |
Subtraction is defined for the following operand types: |
Number-Number,
Date-Number (the number of seconds is
subtracted from the date) |
Multiplication: |
Number*Number |
Division: |
Number/Number |
Residue of division: |
Number%Number |