(42, all flavours) Integer Division - how?
|
12-17-2020, 07:50 PM
Post: #37
|
|||
|
|||
RE: (42, all flavours) Integer Division - how?
(12-17-2020 06:41 PM)Albert Chan Wrote: Your half-way-case had a typo. It should be b := Qq % c Thanks, I corrected it. Quote:If Cc00/Xx fractional part is 0.5, it implied Cc000 / Xx is integer, ends in 5. No.. each 0 is the length of a half integer, so for a 12 digit machine it is 000000 and for Free42/DM42 it's 17 zeroes ;-) Cc00 = Qq*Xx + Rr is the first part of dividing a multiprecision number stored in sequential registers by a number not exceeding a single register: R1 R2 R3 R4 R5 Aa Bb Cc Dd Ee ... / Xx At each step you have the carry from the previous step, Cc, and so you have to do CcYY = Qq*Xx + Rr with Rr next step's Cc. We can only work with 2 letters at the same time, so first Cc00 = Qq*Xx + Rr (as previously covered) t := Yy-Xx+Rr; (because Yy+Rr may overflow) Cc := MOD(t,Xx); IF t>0 then Qq := Qq + (t-Cc)/Xx + 1; end; Yy := Qq; Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 8 Guest(s)