(42, all flavours) Integer Division - how?
|
12-11-2020, 10:48 AM
Post: #1
|
|||
|
|||
(42, all flavours) Integer Division - how?
Anybody know how to implement integer division in a fast and reliable way?
And, no, / IP is not the answer.. Illustrating my point with a hypothetical 2-digit calculator, then: 79 DIV 40 = 1 200 DIV 3 = 66 890 DIV 99 = 8 2300 DIV 40 = 57 the goal is to be able to split Y=Q*X+R when possible, i.e. up to Cc00 = Qq*Xx + Rr with Cc and Rr < Xx, and Cc00 DIV Xx should give Qq (all single letters are half-length integers, or single digits in the case of the 2-digit calculator) 42S equivalents (4e11+39) DIV 40 = 1e10 (/ IP = 1e10+1) 2e12 DIV 3 = 666666666666 (666666666667) 5e23 DIV (1e12-1) = 5e11 (5e11+1) (2e23+3e12) DIV 4e11 = 5e11+7 (5e11+8) (round-to-even, and a particularly difficult one to get right) Free42 equivalents (4e33+39) DIV 40 = 1e32 2e34 DIV 3 = 666...666 I CAN do it, but it's not remotely pretty. It would be a welcome addition to Free42 ;-) Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)