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

Function Dec2Bin

Stack.py:83–93  ·  view source on GitHub ↗
(decNumber)

Source from the content-addressed store, hash-verified

81
82# 利用栈将十进制整数转化为二进制整数
83def Dec2Bin(decNumber):
84 s = Stack()
85
86 while decNumber > 0:
87 temp = decNumber % 2
88 s.push(temp)
89 decNumber = decNumber // 2
90 binString = ''
91 while not s.isEmpty():
92 binString += str(s.pop())
93 return binString
94
95# print(Dec2Bin(42))
96

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