(42, all flavours) Integer Division - how?
|
12-17-2020, 08:53 AM
Post: #33
|
|||
|
|||
RE: (42, all flavours) Integer Division - how?
(12-15-2020 02:51 PM)Albert Chan Wrote: I also added a fast-path, to speed things up. That fast path wouldn't be useful in my case: I wanted to use integer division to correctly split Cc00 = Qq*Xx + Rr, where each letter is a half-length integer and Cc<Xx For instance, in a 2-digit calculator: 2300 = 57*40 + 20, but 2300/40=58 2700 = 37*72 + 36 What I did up till now is determine Q and q separately with Cc0 = Q*Xx + Aa Aa0 = q*Xx + Rr and each split Yy0=Q*Xx+Rr is carried out as Q := Yy0/Xx; Rr := MOD(Yy0,Xx); if FRC(Q) >0 then Q := INT(Q); else if Rr>0 then Q := ROUND(Q - Rr/Xx,0); end; end; sadly, that still is faster than the integer division - mainly because the rounding part is almost never reached, certainly not in the 34-digit Free42.. Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)