Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
manual:chapter6:operators:cmd_ovr_add [2019/10/07 16:03] jojo1973 Template almost finalized. Next update will be definitive |
manual:chapter6:operators:cmd_ovr_add [2019/10/17 14:43] jojo1973 Finished |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== + ==== | + | ==== + (Add) ==== |
---- | ---- | ||
<callout type=" | <callout type=" | ||
Line 9: | Line 9: | ||
---- | ---- | ||
^ __Input Stack__ | ^ __Input Stack__ | ||
- | | **O** | **O** | **→** | + | | **Num< |
+ | | **Num< | ||
+ | | **Num< | ||
+ | | **Num< | ||
+ | | **Z< | ||
+ | | **Z< | ||
+ | | **Z< | ||
+ | | **Z< | ||
+ | | **∡< | ||
+ | | **∡< | ||
+ | | **∡< | ||
+ | | **∡< | ||
+ | | **A< | ||
+ | | **A< | ||
+ | | **A< | ||
+ | | **A< | ||
+ | | **A< | ||
+ | | **U< | ||
+ | | **U< | ||
+ | | **M< | ||
+ | | **V< | ||
+ | | **S< | ||
+ | | **S< | ||
+ | | **O< | ||
| //Level 2 / Argument 1// | //Level 1 / Argument 2// | **→** | | //Level 2 / Argument 1// | //Level 1 / Argument 2// | **→** | ||
Line 16: | Line 39: | ||
|**Type**| [[manual: | |**Type**| [[manual: | ||
|**Parallel list processing**| [[manual: | |**Parallel list processing**| [[manual: | ||
- | |**Affected by flags**|-20| Underflow exception | + | |**Affected by flags**| [[manual: |
- | |:::|-21| Overflow exception | + | |:::| [[manual: |
- | |:::|-22| Infinite result exception | + | |:::| [[manual: |
- | |:::|-23| Negative underflow | + | |:::| [[manual: |
- | |:::|-24| Positive underflow | + | |:::| [[manual: |
- | |:::|-25| Overflow | + | |:::| [[manual: |
- | |:::|-26| Infinite | + | |:::| [[manual: |
</ | </ | ||
<callout color=" | <callout color=" | ||
- | 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, | ||
+ | - if the imaginary part of the sum between a complex number and a scalar is '' | ||
+ | - if the sum between two binary numbers overflows the [[manual: | ||
+ | - 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: | ||
+ | - the sum between a complex and a real number will result in a complex number, except when the imaginary part of the result is '' | ||
+ | - 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 '' | ||
+ | - 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: | ||
+ | |||
+ | If on the contrary one or more of these flags is set, no error will be raised and the matching indicator flag from [[manual: | ||
</ | </ | ||
Line 32: | Line 77: | ||
---- | ---- | ||
This command is only partially compatible with userRPL. | This command is only partially compatible with userRPL. | ||
+ | |||
+ | In particular: | ||
+ | * coercion rules give precedence to first argument rather than the second; | ||
+ | * the '' | ||
</ | </ | ||
<callout type=" | <callout type=" | ||
---- | ---- | ||
- | The following program: | ||
< | < | ||
- | « 123 | + | 2: #120o |
- | 456 | + | 1: #3h |
- | 789 | + | …………………………………………………………………………………… |
- | DROP | + | + |
- | » | + | </ |
+ | returns ''# | ||
+ | ---- | ||
+ | < | ||
+ | 2: (1, ∡60°) | ||
+ | 1: 5 | ||
+ | …………………………………………………………………………………… | ||
+ | + | ||
+ | </ | ||
+ | returns '' | ||
+ | ---- | ||
+ | < | ||
+ | 2: "Hello " | ||
+ | 1: " | ||
+ | …………………………………………………………………………………… | ||
+ | + | ||
+ | </ | ||
+ | returns ''" | ||
+ | ---- | ||
+ | < | ||
+ | 2: 1_h | ||
+ | 1: 36_min | ||
+ | …………………………………………………………………………………… | ||
+ | + | ||
+ | </ | ||
+ | returns '' | ||
+ | ---- | ||
+ | < | ||
+ | 2: [ 1 2 ] | ||
+ | 1: [ 1 0 ] | ||
+ | …………………………………………………………………………………… | ||
+ | + | ||
+ | </ | ||
+ | returns '' | ||
+ | ---- | ||
+ | < | ||
+ | 2: ' | ||
+ | 1: ' | ||
+ | …………………………………………………………………………………… | ||
+ | + | ||
</ | </ | ||
- | leaves | + | returns |
</ | </ | ||