hex.div¶
if b==0: goto div0
q = a/b (unsigned division)
r = a%b (unsigned modulo)
@NOTE: a,b are UNSIGNED numbers. If you want a division with signed ints, use the idiv macro.
q,a are hex[:n], while r,b are hex[:nb]. div0 is the bit-address this function will jump to in-case b is zero.
Signature¶
def div n, nb, q, r, a, b, div0 @ loop, after_loop, half_b__sub_if_bigger, do_sub, jump_to_flip, flip_op, _r, _b, _a, i, ret, end { ... }
Defined in hex/div.fj — lines 11–70 (view on GitHub).
Complexity¶
Time:
n^2(2@+8) + n*nb(34@+92) so if nb==n: n^2(36@+100)Space:
n(4@+81) + nb(16@+243) so if nb==n: n(20@+324)
See the complexity glossary for what @, w, dw, dbit, n mean.
Requires init¶
The following must be initialised before this macro is invoked:
hex.sub.init & hex.cmp.init (or hex.init)