==== + (Add) ==== ---- ---- Return the sum of the arguments ---- ^ __Input Stack__ ^^ ^ __Output Stack__ ^ | **Num1** | **Num2** | **→** | **Num3** | | **Num1** | **Z2** | **→** | **Z3** | | **Num1** | **∡2** | **→** | **∡3** | | **Num1** | **A2** | **→** | **'Num1 + A2'** | | **Z1** | **Z2** | **→** | **Z3** | | **Z1** | **Num2** | **→** | **Z3** | | **Z1** | **∡2** | **→** | **Z3** | | **Z1** | **A2** | **→** | **'Z1 + A2'** | | **∡1** | **∡2** | **→** | **∡3** | | **∡1** | **Num2** | **→** | **∡3** | | **∡1** | **Z2** | **→** | **Z3** | | **∡1** | **A2** | **→** | **'∡1 + A2'** | | **A1** | **A2** | **→** | **'A1 + A2'** | | **A1** | **Num2** | **→** | **'A1 + Num2'** | | **A1** | **Z2** | **→** | **'A1 + Z2'** | | **A1** | **U2** | **→** | **'A1 + U2'** | | **A1** | **∡2** | **→** | **'A1 + ∡2'** | | **U1** | **U2** | **→** | **U3** | | **U1** | **A2** | **→** | **'U1 + A2'** | | **M1** | **M2** | **→** | **M3** | | **V1** | **V2** | **→** | **V3** | | **S1** | **S2** | **→** | **"S1S2"** | | **S1** | **O2** | **→** | **"S1O2"** | | **O1** | **S2** | **→** | **"O1S2"** | | //Level 2 / Argument 1// | //Level 1 / Argument 2// | **→** | //Level 1// | {{page>manual:chapter6:aux:legend&nofooter&noeditbtn&inline}} |**Type**| [[manual:chapter5:basics#operators|Operator]] || |**Parallel list processing**| [[manual:chapter5:listproc#group-6two-arguments-one-result-commands|Group 6]] || |**Affected by flags**| [[manual:appendix:flags#flag-20|-20]] | Underflow exception | |:::| [[manual:appendix:flags#flag-21|-21]] | Overflow exception | |:::| [[manual:appendix:flags#flag-22|-22]] | Infinite result exception | |:::| [[manual:appendix:flags#flag-23|-23]] | Negative underflow indicator | |:::| [[manual:appendix:flags#flag-24|-24]] | Positive underflow indicator | |:::| [[manual:appendix:flags#flag-25|-25]] | Overflow indicator | |:::| [[manual:appendix:flags#flag-26|-26]] | Infinite result indicator | ---- 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 [[manual:chapter3:numformat|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 [[manual:chapter2:interface|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 ''[[manual:chapter6:binary:cmd_badd|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 [[manual:chapter3:numformat|underflow]], [[manual:chapter3:numformat|overflow]] or [[manual:chapter3:infinity|infinite]] result will raise an error if one of the corresponding flags from [[manual:appendix:flags#flag-20|-20]] to [[manual:appendix:flags#flag-22|-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 [[manual:appendix:flags#flag-23|-23]] to [[manual:appendix:flags#flag-26|-26]] will be set. ---- This command is only partially compatible with userRPL. In particular: * coercion rules give precedence to first argument rather than the second; * the ''+'' operator **does not** concatenate or extend lists anymore: use ''[[manual:chapter6:lists:cmd_add|ADD]]'' instead. ---- 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'%%''. ---- {{page>manual:chapter6:operators&nofooter&noeditbtn&inline}}