Skip to content

Instantly share code, notes, and snippets.

@CapsAdmin
Created May 21, 2019 15:48
Show Gist options
  • Save CapsAdmin/ffa464314b4c51dedbf7f4640b9b698e to your computer and use it in GitHub Desktop.
Save CapsAdmin/ffa464314b4c51dedbf7f4640b9b698e to your computer and use it in GitHub Desktop.
local ffi = require("ffi")
local cast = ffi.cast
local ctype = ffi.typeof("float *")
local function get_num(bytes)
local res = cast(ctype, bytes)[0]
if not res then
print(res, type(res), res or 0)
res = 0
end
return res
end
local num = 0
while true do
local bytes = "\xFF\xFF\xFF" .. string.char(math.random(250, 255))
local res = get_num(bytes)
print(num, res)
num = num + res
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment