Difference between revisions of "Bit32.lrotate"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 7: | Line 7: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
(number) = bit32.lrotate(x,disp) | (number) = bit32.lrotate(x,disp) | ||
− | </ | + | </syntaxhighlight> |
Returns the number x rotated disp bits to the left. | Returns the number x rotated disp bits to the left. | ||
Line 14: | Line 14: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32)) | assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32)) | ||
− | </ | + | </syntaxhighlight> |
'''Negative displacements rotate to the right''' | '''Negative displacements rotate to the right''' |
Latest revision as of 14:26, 13 July 2023
Available since: Gideros 2022.3
Class: bit32
Description
Returns a number after its bits have been rotated to the left by a given number of times.
(number) = bit32.lrotate(x,disp)
Returns the number x rotated disp bits to the left.
The number disp may be any representable integer. For any valid displacement, the following identity holds:
assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32))
Negative displacements rotate to the right
Parameters
x: (number) value
disp: (number) displacement
Return values
Returns (number) result after bits left rotation
See also