Post Reply 
(42, all flavours) Integer Division - how?
12-13-2020, 04:21 PM (This post was last modified: 12-13-2020 04:22 PM by Albert Chan.)
Post: #15
RE: (42, all flavours) Integer Division - how?
(12-13-2020 01:18 PM)Albert Chan Wrote:  We had assumed q never overflow, which results in |r| ≤ 1

Assuming q is correctly rounded (mode round-to-nearest), r = 0 or -1

The code is simplified to correct, or not correct.

PHP Code:
function idiv3(a,b)         -- assumed b 0
    local q
floor(a/b), b+1
    a
a%a%cq%c   -- a-= [2-2cc-2]
    if 
a==or a==b-c then return q end    
    
return q-1
end 
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-13-2020 04:21 PM



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