Bit32.rrotate: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2022.3<br/> '''Class:''' bit32<br/> === Description === Returns a number after its bits have been rotated to the right by a given..."
 
m Text replacement - "</source>" to "</syntaxhighlight>"
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
=== Description ===
=== Description ===
Returns a number after its bits have been rotated to the right by a given number of times.
Returns a number after its bits have been rotated to the right by a given number of times.
<source lang="lua">
<syntaxhighlight lang="lua">
(number) = bit32.rrotate(x,disp)
(number) = bit32.rrotate(x,disp)
</source>
</syntaxhighlight>


Returns the number x rotated disp bits to the right.
Returns the number x rotated disp bits to the right.


The number disp may be any representable integer. For any valid displacement, the following identity holds:
The number disp may be any representable integer. For any valid displacement, the following identity holds:
<source lang="lua">
<syntaxhighlight lang="lua">
assert(bit32.rrotate(x, disp) == bit32.rrotate(x , disp % 32))
assert(bit32.rrotate(x, disp) == bit32.rrotate(x , disp % 32))
</source>
</syntaxhighlight>


  '''Negative displacements rotate to the left'''
  '''Negative displacements rotate to the left'''

Latest revision as of 13:27, 13 July 2023

Available since: Gideros 2022.3
Class: bit32

Description

Returns a number after its bits have been rotated to the right by a given number of times.

(number) = bit32.rrotate(x,disp)

Returns the number x rotated disp bits to the right.

The number disp may be any representable integer. For any valid displacement, the following identity holds:

assert(bit32.rrotate(x, disp) == bit32.rrotate(x , disp % 32))
Negative displacements rotate to the left

Parameters

x: (number) value
disp: (number) displacement

Return values

Returns (number) result after bits right rotation

See also

Bitwise Operators