bit.idiv

Signed integer division: q = a/b, r = a%b with sign(r)==sign(a). Jumps to end if b==0. q, a, b, r are bit[:n]. Wasteful in space — prefer hex.idiv for serious work.

Signature

def idiv n, a, b, q, r @ negative_a, negative_b, one_negative, neg_b_1, do_div, neg_b_2, neg_ans, end { ... }

Defined in bit/div.fj — lines 64–97 (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.

Source

Depends on


← Previous: bit.div10.cmp_sub_10 Next: bit.div