from math import log2, ceil, floor BW = 5 BE = 3 EO = 1 BM = BW-BE BO = BM-EO # BW-BE-EO EXP_MAX = 2**BE-1 R_MIN = ufp_to_r(EXP_MAX, 1, BW, BE, EO) def r_to_ufp(r, BW, BE, EO): BM = BW-BE BO = BM-EO # BW-BE-EO EXP_MAX = 2**BE-1 R_MIN = ufp_to_r(EXP_MAX, 1, BW, BE, EO) if r