Post Reply 
(42, all flavours) Integer Division - how?
12-13-2020, 12:09 PM
Post: #13
RE: (42, all flavours) Integer Division - how?
All that is left is to turn it in a routine..First try:
Code:
 { 38-Byte Prgm } @     X       Y       Z       T
 LBL "DIV" @            b       a
 RCL ST Y
 RCL ST Y
 /
 IP @                   q       b       a       a
 Rv
 MOD @          b       r       a       q       q
 X<>Y
 1
 STO+ ST Z
 RCL+ ST L @            c       a       r+1     q
 MOD
 STO- ST Y @    c       R       r+1-R   q       q
 X<> ST T
 LASTX
 MOD @          c       q%c     r+1-R   q       q
 STO- ST Y
 X<> ST L @             c       r'      q       q
 MOD
 +
 DSE ST X
 END

I can recover b too, if needed, but that's it.

Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (42, all flavours) Integer Division - how? - Werner - 12-13-2020 12:09 PM



User(s) browsing this thread: 1 Guest(s)