Page 1 of 1

General arithmetic with memory

Posted: Thu Feb 05, 2004 10:35 am
by hlreed
We have had Out = Out + In
That can be extended.
Out = Out + In1 f In2 ;where f is any arithmetic operator.<p>MP = MP + I1 + I2
MM = MP + I1 - I2
MO = MO + MAX(I1,I2)
MA = MA + MIN(I1,I2)<p>Interesting to note that MP + MM = 0 and
MO + MA = MP<p>General code, with Out, In and Ref is:<p>BEGIN Marith
1. Out = 0 ; initialize Out
Loop
2. Read In
3. Read Ref
4. Out = Out + In f Ref
5. Write Out
6. Go to Loop ;what makes this work
END Marith<p>Here is a tree:
O1 = O1 + A + B
O2 = O2 + C + D
O3 = O3 + O1 + O2
So O3 = O3 + O2 + O1 <p>These are not conditional. Feed in a one and you get a count. Takes a computer to do these. Have a spread sheet if you ask.