Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Division Algorithm

Name: Anonymous 2018-10-21 13:04

How does one divide a by b, given there is not division operation (i.e. C64 or NES)?

So far I got the following algorithm:
def div(a,b):
if a < b: return 0
if b == 0: raise Exception('Division by zero.')
q = 1
t = a
while t>>1 >= b:
t >>= 1
q <<= 1
return q + div(a-q*b,b)


guess it is O(n), where n is the number of bits in a. But NES also has no multiplication opcode, so q*b will require O(log2(n)) additions. How does one implement it properly? How CPUs implement division?

Name: Anonymous 2018-10-23 7:05

>>29
what does 'infinite length' even mean? does it mean irrational numbers? if so, you can trivially construct a finite or countably infinite set of irrationals - e.g. a set which consists of integers multiplied by pi. that's still countable. or maybe you mean that its elements are sets of infinite length? that makes even less sense, and you can still trivially construct a countably infinite set of infinite sets - e.g. a set which contains sets of { { 1... ∞ }, {2 ... ∞ }, ... , { n ... ∞ }}

countably infinite sets don't have finite elements, they have finite continuous subsets (not even all subsets - a set of even integers is a subset of set of integers and it's still infinite). in other words, a countably infinite set will have a finite number of elements between two arbitrarily chosen elements - e.g. 'integers larger than 1 and smaller than 10'. in uncountably infinite sets, those subsets can be infinite - e.g. 'real numbers larger than 1 and smaller than 10'. an intuitive way of looking at that would be: if you pick a number from countably infinite set, you can easily point to next/previous number. in an uncountably infinite set, you can't because there's still infinite number of elements between 'current' and 'next'

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List