模块:Hydrogina/sandbox/tobin

可在模块:Hydrogina/sandbox/tobin/doc创建此模块的帮助文档

p={}

function byte2bin(n)
	local t = {}
	for i=4,0,-1 do
		t[#t+1] = math.floor(n / 2^i)
		n = n % 2^i
	end
	return table.concat(t)
end


function make_bin(n,mode)
	n=tonumber(n)
	if(mode=="HIGH") then
		numsub=math.floor(n / 32)
	else
		numsub=math.fmod(n,32)
	end
		
	rtn=byte2bin(numsub)
	return rtn
end

function p.get(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	n=args[1]
	mode=args[2]
	rtn=make_bin(n,mode)
	return rtn
end
return p