MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / baseConverter

Function baseConverter

Stack.py:98–112  ·  view source on GitHub ↗
(decNumber, base)

Source from the content-addressed store, hash-verified

96
97# 利用栈实现多进制转换
98def baseConverter(decNumber, base):
99 digits = '0123456789ABCDEF'
100
101 s = Stack()
102
103 while decNumber > 0:
104 temp = decNumber % base
105 s.push(temp)
106 decNumber = decNumber // base
107
108 newString = ''
109 while not s.isEmpty():
110 newString = newString + digits[s.pop()]
111
112 return newString
113
114# print(baseConverter(59, 16))
115

Callers

nothing calls this directly

Calls 4

pushMethod · 0.95
isEmptyMethod · 0.95
popMethod · 0.95
StackClass · 0.85

Tested by

no test coverage detected