Difference between revisions of "Bit32.arshift"

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.arshift(x,disp)
 
(number) = bit32.arshift(x,disp)
</source>
+
</syntaxhighlight>
  
 
  '''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)'''
 
  '''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)'''

Latest revision as of 14:27, 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.

(number) = bit32.arshift(x,disp)
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