bit = require(“bit”)
this is generating an error message … is there an updated way to accomplish this snippet below?
if bit.band(b, ls) == b then
return v
end
bit = require(“bit”)
this is generating an error message … is there an updated way to accomplish this snippet below?
if bit.band(b, ls) == b then
return v
end
What machine are you running this on? Your Lua installation may not have this installed by default.
(I moved this to a new topic from an eight-year-old thread.)
either that or you have an oriented quote copy paste problem…
where
bit = require(“bit”)
should be
bit = require("bit")
There are a number of bit libraries around: bit, bit32, … and they are rather compatible.
I use the following snippet I found on CRC32 in pure lua - Pastebin.com so I don’t have to bother which one is used:
local function requireany(...)
local errs = {}
for _,name in ipairs{...} do
if type(name) ~= 'string' then return name, '' end
local ok, mod = pcall(require, name)
if ok then return mod, name end
errs[#errs+1] = mod
end
error(table.concat(errs, '\n'), 2)
end
-- Try to use whatever bit-manipulation library that is available
local bit, _ = requireany('bit', 'nixio.bit', 'bit32', 'bit.numberlua')
Hi,
I think all Veras have nixio installed. Seems quite a complete set of functions. probably should look into it a bit more.
Cheers Rene
Best Home Automation shopping experience. Shop at Ezlo!
© 2022 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules