hex/math.fjΒΆ
βββ- Addition / Subtraction:
MacrosΒΆ
hexΒΆ
hex.add/2βdst += srchex.add/3βdst[:n] += src[:n]hex.add_shiftedβdst[:dst_n] += src[:src_n] << (4*hex_shift)hex.add_constantβdst[:n] += consthex.sub/2βdst -= srchex.sub/3βdst[:n] -= src[:n]hex.sub_shiftedβdst[:dst_n] -= src[:src_n] << (4*hex_shift)hex.sub_constantβdst[:dst_n] -= const
hex.addΒΆ
hex.add.add_constant_with_leading_zerosβ Internal helper forhex.add_constant: stripsconstβs trailing zero nibbles, then adds the result back intodst[:n]at the matching β¦hex.add.add_hex_shifted_constant/4β Wrapper around the 5-arityadd_hex_shifted_constant: derivesn_const = (#const + 3) / 4automatically so the caller doesnβt have to β¦hex.add.add_hex_shifted_constant/5βdst[:dst_n] += const << (4*hex_shift)hex.add.clear_carry/0βcarry = 0hex.add.clear_carry/2βcarry = 0. jump to c0 if it was 0, and to c1 otherwise.hex.add.not_carryβcarry = !carryhex.add.set_carryβcarry = 1hex.add.initβ Its 9-bits are expected to be {carry<<8 |src<<4 | dst} at the jump to it (for the src,dst hexes, and the carry bit, of the β¦
hex.subΒΆ
hex.sub.sub_constant_with_leading_zerosβ Internal helper forhex.sub_constant: stripsconstβs trailing zero nibbles, then subtracts the result fromdst[:n]at the matching β¦hex.sub.sub_hex_shifted_constant/4β Wrapper around the 5-aritysub_hex_shifted_constant: derivesn_const = (#const + 3) / 4automatically so the caller doesnβt have to β¦hex.sub.sub_hex_shifted_constant/5βdst[:dst_n] -= const << (4*hex_shift)hex.sub.clear_carry/0βcarry = 0hex.sub.clear_carry/2βcarry = 0. jump to c0 if it was 0, and to c1 otherwise.hex.sub.not_carryβcarry = !carryhex.sub.set_carryβcarry = 1hex.sub.initβ Its 9-bits are expected to be {carry<<8 |src<<4 | dst} at the jump to it (for the src,dst hexes, and the carry bit, of the β¦