bitArShift
Client-side
Server-side
Shared
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This functions performs an arithmetic shift on the integer value by integer n positions. In an arithmetic shift, zeros are shifted in to replace the discarded bits. In a right arithmetic shift, the sign bit is shifted in on the left, thus preserving the sign of the operand. See Bitwise operation for more details.
Syntax
bitArShift ( )Code Examples
server
This example adds the clientside command/arshift [value] [positions = 1], which will print the result from the functionbitArShift.
function getNumberAsBitString(value) if type(value) ~= 'number' then return false else local binary = ''
for field = 31, 0, -1 do binary = binary .. bitExtract(value, field)
if field % 4 == 0 then binary = binary ..' ' end end
return binary endend
addCommandHandler('arshift', function (command, value, positions) if type(value) ~= 'string' or value:len() == 0 then return outputChatBox('* Syntax: /arshift [value] [positions = 1]') end
if type(positions) ~= 'string' or positions:len() == 0 then positions = 1 end
local result = bitArShift(tonumber(value), tonumber(positions)) local binary = getNumberAsBitString(result)
outputChatBox('* Decimal: '.. result ..', Binary: '.. binary) end)See Also
Utility Functions
- addDebugHook
- bitAnd
- bitArShift
- bitExtract
- bitLRotate
- bitLShift
- bitNot
- bitOr
- bitReplace
- bitRRotate
- bitRShift
- bitTest
- bitXor
- createTrayNotification
- debugSleep
- decodeString
- deref
- downloadFile
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getFPSLimit
- getKeyboardLayout
- getLocalization
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getProcessMemoryStats
- getRealTime
- getServerIp
- getTickCount
- getTimerDetails
- getTimers
- gettok
- getUserdataType
- getVersion
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isShowCollisionsEnabled
- isShowSoundEnabled
- isTimer
- isTimerPaused
- isTransferBoxAlwaysVisible
- isTransferBoxVisible
- isTrayNotificationEnabled
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- ref
- removeDebugHook
- resetTimer
- setClipboard
- setDevelopmentMode
- setFPSLimit
- setTimer
- setTimerPaused
- setTransferBoxVisible
- setWindowFlashing
- sha256
- showCol
- showSound
- split
- teaDecode
- teaEncode
- tocolor
- toJSON
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub