hex/math_basic.fj

———- Basic Mathematics:

View source on GitHub

Macros

hex

  • hex.add_count_bitsdst[:n] += src.#on-bits (between 0->4)

  • hex.count_bitsdst[:small_n] = x[:n].#on-bits

  • hex.inc1hex++ (if overflows - jump to carry1; else jump to carry0)

  • hex.inchex[:n]++

  • hex.dec1hex-- (if underflows - jump to borrow1; else jump to borrow0)

  • hex.dechex[:n]--

  • hex.negx[:n] = -x[:n]

  • hex.absx[:n] = |x[:n]| (two’s complement; the minimal value -2^(4n-1) stays itself)

  • hex.sign_extendsign-extends hex[:signed_n] into hex[:full_n]

hex.inc

  • hex.inc.step — One nibble of a propagating increment: increment hex by 1; on overflow continue to the next nibble, else jump to end.

hex.dec

  • hex.dec.step — One nibble of a propagating decrement: decrement hex by 1; on underflow continue to the next nibble, else jump to end.