Difference between revisions of "Bit32.arshift"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2022.3<br/> '''Class:''' bit32<br/> === Description === Returns the number x shifted disp bits to the right. The number disp may...")
 
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left.
 
Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number) = bit32.arshift(x,disp)
 
(number) = bit32.arshift(x,disp)
 
</source>
 
</source>

Revision as of 15:26, 13 July 2023

Available since: Gideros 2022.3
Class: bit32

Description

Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left. <syntaxhighlight lang="lua"> (number) = bit32.arshift(x,disp) </source>

This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of x; vacant bits on the right are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero or 0xFFFFFFFF (all original bits are shifted out)

Parameters

x: (number) the number whose bits shall be shifted
disp: (number) the integer number of bits to shift by

Return values

Returns (number) result

See also

Bitwise Operators