-- Converts a byte to a string of 0s and 1s. function byte2bin(n) local t = {} for i=7,0,-1 do t[#t+1] = math.floor(n / 2^i) n = n % 2^i end return table.concat(t) end
a = byte2bin(127)
print(a)
輸出:
01111111
原文 :
-- Converts a byte to a string of 0s and 1s. function byte2bin(n) local t = {} for i=7,0,-1 do t[#t+1] = math.floor(n / 2^i) n = n % 2^i end return table.concat(t) end
a = byte2bin(127)
print(a)
輸出:
01111111
原文 :
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。