MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / to_base16

Function to_base16

pygorithm/binary/base2.py:83–102  ·  view source on GitHub ↗

Convert binary numbers to hexadecimal numbers :param n: binary number :param visualize: Visualise the process :return: hexadecimal number

(n, visualize=False)

Source from the content-addressed store, hash-verified

81
82
83def to_base16(n, visualize=False):
84 """
85 Convert binary numbers to hexadecimal numbers
86
87 :param n: binary number
88 :param visualize: Visualise the process
89 :return: hexadecimal number
90 """
91 grouped_list = __create_group_list(n)
92 _list = []
93 for value in grouped_list:
94 if visualize:
95 print("{} -> {}".format(value, BINARY_HEX_VALUES[value]))
96 # for each value in the grouped_list,
97 # get its respective value from the hex
98 # table by referencing the key with the
99 # current value from the grouped_list
100 _list.append(BINARY_HEX_VALUES[value])
101
102 return ''.join(_list)
103
104
105def __create_group_list(n):

Callers

nothing calls this directly

Calls 1

__create_group_listFunction · 0.85

Tested by

no test coverage detected