bit.div¶

if b==0: goto end (do nothing)
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.
@NOTE: this division implementation is WASTEFUL in space, yet saves running time, compared to div_loop.

@NOTE: There is a better version: This one is slow, big, and doesn’t error on b==0.
For a faster & better division see hex.div, hex.idiv.
q,a,b,r are bit[:n].

Signature¶

def div n, a, b, q, r @ Q, R, end { ... }

Defined in bit/div.fj — lines 108–124 (view on GitHub).

Complexity¶

  • Time: n^2(10@+20)

  • Space: n^2(11@+22)

See the complexity glossary for what @, w, dw, dbit, n mean.

Depends on¶

Used by¶