lua测试

This commit is contained in:
ranchuan
2023-06-29 18:12:56 +08:00
parent 28889fa479
commit 156d1ceeb4
5 changed files with 84 additions and 19 deletions

View File

@@ -1,6 +1,13 @@
-- 2023.6.29
-- 使用算数运算代替位运算
module = {}
function module:print_t ( t )
@@ -45,12 +52,13 @@ function byte_to_hex(byte,size)
local str_ret=""
if(size==2) then
str_ret=string.char(
string.byte( str_table,((byte>>12)&0xf)+1),
string.byte( str_table,((byte>>8)&0xf)+1),
string.byte( str_table,((byte>>4)&0xf)+1),
string.byte(str_table,(byte&0xf)+1))
-- 右移12位//4096
string.byte( str_table,(math.floor(byte/4096)%16)+1),
string.byte( str_table,(math.floor(byte/256)%16)+1),
string.byte( str_table,(math.floor(byte/16)%16)+1),
string.byte(str_table,(byte%16)+1))
else
str_ret=string.char(string.byte(str_table,(byte%256)//16+1),string.byte(str_table,(byte%256)%16+1))
str_ret=string.char(string.byte(str_table,math.floor((byte%256)/16)+1),string.byte(str_table,(byte%256)%16+1))
end
return str_ret
end