Replies: 2 comments 2 replies
-
The range is always -9999 to +9999 ? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here is how I would do it! ushort= 65535 -- mask signed short integer myMethod = function(--[[ CtrlrModulator --]] mod --[[ number --]], value --[[ number --]], source) local bi = BigInteger(luaIntMask(value)) local MS = bi:getBitRangeAsInt(0, 4) local LS = bi:getBitRangeAsInt(4, 4) local MS1 = bi:getBitRangeAsInt(8, 4) local LS1 = bi:getBitRangeAsInt(12, 4) console(string.format("%.2x %.2x %.2x %.2x", MS, LS, MS1, LS1)) end function luaIntMask(val, mask) local mask = mask or ushort return bit.band(val, mask) end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everyone
local bi = BigInteger(value)
local MS = bi:getBitRangeAsInt(0,4)
local LS = bi:getBitRangeAsInt(4, 4)
local MS1 = bi:getBitRangeAsInt(8,4)
local LS1 = bi:getBitRangeAsInt(12,4)
this works for me with positive values but i need to go negative
starting by:
0 = 00 00 00 00
-1 = 0f 0f 0f 0f
-2 = 0e 0f 0f 0f
-3 = 0d 0f 0f 0f
...
-9999 = 01 0f 08 0d
anyone know how to calculate`?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions