+

( n1 | u1 n2 | u2 -- n3 | u3 )

Add n2 | u2 to n1 | u1, giving the sum n3 | u3.

See:

Testing:

T{        0  5 + ->          5 }T
T{        5  0 + ->          5 }T
T{        0 -5 + ->         -5 }T
T{       -5  0 + ->         -5 }T
T{        1  2 + ->          3 }T
T{        1 -2 + ->         -1 }T
T{       -1  2 + ->          1 }T
T{       -1 -2 + ->         -3 }T
T{       -1  1 + ->          0 }T
T{ MID-UINT  1 + -> MID-UINT+1 }T

ContributeContributions

mcondronavatar of mcondron Overflow/underflowRequest for clarification2019-05-21 23:30:20

After realizing that +LOOP can overflow or underflow, it occurred to me...is that state something that ALL the arithmetic operators should detect? Should it be 1) ignored, 2) a flag that a program can test, 3) an error/exception?? Maybe this issue is addressed somewhere in sections 1-4 of the Standard?

AntonErtlavatar of AntonErtl 2019-05-22 07:24:15

Section 3.2.2.2 specifies the behaviour on overflow or underflow. The next standard will refine this; see the proposal 2s-Complement Wrap-Around Integers.

Reply