hex.divΒΆ

Unsigned integer division: q = a/b, r = a%b. Jumps to div0 if b==0. q, a are hex[:n]; r, b are hex[:nb].

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)

SourceΒΆ

Depends onΒΆ

Used byΒΆ

Example usesΒΆ


Next: hex.idiv β†’