Post Reply 
(42, all flavours) Integer Division - how?
12-21-2020, 07:35 PM
Post: #55
RE: (42, all flavours) Integer Division - how?
(12-21-2020 03:20 PM)Albert Chan Wrote:  a = q*b + s*h
a-h ≡ q*b (mod 9), if s=1

I was being stupid, why mod 9 test, when we could do mod 10 ? Big Grin
Again, b cannot have factors of 10 (nonzero last digit)

Redoing previous post examples, but with mod-10 test

a/b = 6900 / 120 = 690 / 12 = 57.5
q = 58
h = b/2 = 6

a-h ≡ 0 - 6 ≡ 4
q·b ≡ 8 * 2 ≡ 6
→ s≠1, return q-1 = 57

2nd example a = -a; q = -q

a-h ≡ (-0) - 6 ≡ 4
q·b ≡ (-8) * 2 ≡ 4
→ s=1, return q = -58
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? - Albert Chan - 12-21-2020 07:35 PM



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