**This is an old revision of the document!**

### + (Add)

#### Synopsis

Return the sum of the arguments

#### Stack Diagram

Input Stack | Output Stack |
||
---|---|---|---|

Num _{1} | Num _{2} | → | Num _{3} |

Num _{1} | Z _{2} | → | Z _{3} |

Num _{1} | ∡ _{2} | → | ∡ _{3} |

Num _{1} | A _{2} | → | 'Num _{1} + A_{2}' |

Z _{1} | Z _{2} | → | Z _{3} |

Z _{1} | Num _{2} | → | Z _{3} |

Z _{1} | ∡ _{2} | → | Z _{3} |

Z _{1} | A _{2} | → | 'Z _{1} + A_{2}' |

∡ _{1} | ∡ _{2} | → | ∡ _{3} |

∡ _{1} | Num _{2} | → | ∡ _{3} |

∡ _{1} | Z _{2} | → | Z _{3} |

∡ _{1} | A _{2} | → | '∡ _{1} + A_{2}' |

A _{1} | A _{2} | → | 'A _{1} + A_{2}' |

A _{1} | Num _{2} | → | 'A _{1} + Num_{2}' |

A _{1} | Z _{2} | → | 'A _{1} + Z_{2}' |

A _{1} | U _{2} | → | 'A _{1} + U_{2}' |

A _{1} | ∡ _{2} | → | 'A _{1} + ∡_{2}' |

U _{1} | U _{2} | → | U _{3} |

U _{1} | A _{2} | → | 'U _{1} + A_{2}' |

M _{1} | M _{2} | → | M _{3} |

V _{1} | V _{2} | → | V _{3} |

S _{1} | S _{2} | → | “S _{1}S_{2}“ |

S _{1} | O _{2} | → | “S _{1}O_{2}“ |

O _{1} | S _{2} | → | “O _{1}S_{2}“ |

Level 2 / Argument 1 | Level 1 / Argument 2 | → | Level 1 |

#### Description

In general if the arguments of the sum have the same type so will do the result. However same data types may have different sub-types; in this case the following coercion rules apply:

- the sub-type of the first argument determines the sub-type of the result: e.g. the sum between an hexadecimal and an octal integer will be hexadecimal, the sum between an angle in radians and an angle in degrees will be in radians, and so on;
- if the imaginary part of the sum between a complex number and a scalar is
`0`

the result will be coerced to real type; - if the sum between two binary numbers overflows the range of binary sub-type the result will be coerced to real type;
- the sum between two unit objects is possible only if the two are dimensionally coherent;
- the sum between two matrices is possible only if they have the same dimension;
- the sum between two vectors is possible only if they have the same dimension.

If the arguments of the sum have different type the following rules apply:

- the sum between an angle and a real number will interpret the real number as an angle given in the current angle mode. The result will be an angle expressed in the system of the first argument (current mode if the first argument is the real number);
- the sum between a complex and a real number will result in a complex number, except when the imaginary part of the result is
`0`

: in this case the result will be coerced to real type; - the sum between an angle and a complex number will
**convert the angle to a real number expressing the angle in radians**. Subsequently the real number will be added to the complex number according to the rule above; - when adding two binary integers the binary wordsize is
**NOT**taken into account. Use`BADD`

if truncation to wordsize is desired; - dimensionless units are coherent with scalars and angles therefore they can be added.

The sum between two matrices or two vectors is done element by element: for each couple of elements the rules above are applied.

Occurrence of underflow, overflow or infinite result will raise an error if one of the corresponding flags from -20 to -22 is cleared.

If on the contrary one or more of these flags is set, no error will be raised and the matching indicator flag from -23 to -26 will be set.

#### Compatibility

This command is only partially compatible with userRPL.

In particular:

- coercion rules give precedence to first argument rather than the second;

#### Usage

2: #120o 1: #3h …………………………………………………………………………………… +

returns `#123o`

.

2: (1, ∡60°) 1: 5 …………………………………………………………………………………… +

returns `(5.5678., ∡8.9483.°)`

.

2: "Hello " 1: "world!" …………………………………………………………………………………… +

returns `“Hello world!”`

.

2: 1_h 1: 36_min …………………………………………………………………………………… +

returns `1.6_h`

.

2: [ 1 2 ] 1: [ 1 0 ] …………………………………………………………………………………… +

returns `[ 2 2 ]`

.

2: 'X' 1: 'Y' …………………………………………………………………………………… +

returns `'X+Y'`

.

#### Related Commands

Operator | Short Description | |
---|---|---|

Evaluation operators: |
||

EVAL1 | Evaluate one level | NEW |

EVAL | Evaluate full depth | |

XEQ | Execute | NEW |

→NUM | Compute numeric result | |

Test operators: |
||

== | Equality test | |

≠ | Not equal test | |

< | Less than test | |

≤ | Less than or equal test | |

> | Greater than test | |

≥ | Greater than or equal test | |

CMP | Comparison test (<0 if A<B, 0 if A==B, >0 if A>B) | NEW |

SAME | Comparison test, true if objects are the same | |

ISTRUE | True test | NEW |

Logical operators: |
||

AND | Logical AND | |

OR | Logical OR | |

XOR | Logical XOR | |

NOT | Logical NOT | |

Mathematic operators: |
||

+ | Addition | |

- | Subtraction | |

* | Multiplication | |

/ | Division | |

^ | Power | |

XROOT | Root | |

INV | Inverse | |

NEG | Negate/change sign | |

ABS | Magnitude or absolute value |