hex/math.fjΒΆ
βββ- Addition / Subtraction:
MacrosΒΆ
hexΒΆ
hex.add/2β both dst,src are hexes.hex.add/3βdst[:n] += src[:n]hex.add_shiftedβdst[:dst_n] += src[:src_n] << (4*hex_shift)hex.add_constantβ const must be a positive constant.hex.sub/2β both dst,src are hexes.hex.sub/3βdst[:n] -= src[:n]hex.sub_shiftedβdst[:dst_n] -= src[:src_n] << (4*hex_shift)hex.sub_constantβ n_const is thehex-lengthof const, without all of itβsleast-significant-hexeszeros.
hex.addΒΆ
hex.add.add_hex_shifted_constant/5β const is a constant of sizehex[:n_const]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β This is where the add βtruthβ tables are.
hex.subΒΆ
hex.sub.sub_hex_shifted_constant/5β const is a constant of sizehex[:n_const]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β This is where the sub βtruthβ tables are. must be called once if you want to use hex.sub (hex.init calls it).