bit32.arshift

bit32.arshift (n: number, i: number) -> number

Shifts n by i bits to the right (if i is negative, a left shift is performed instead). The most significant bit of n is propagated during the shift. When i is larger than 31, returns an integer with all bits set to the sign bit of n. When i is smaller than -31, 0 is returned

Example

bit32.arshift(3.14, 3.14)
Raw function spec json
{
  "def": "func",
  "name": "arshift",
  "energy": 0,
  "must_use": true,
  "sleep": 0,
  "signatures": [
    {
      "def": "signature",
      "result": [
        {
          "name": "",
          "def": "result",
          "desc": "",
          "variadic": false,
          "type": [
            {
              "def": "simple",
              "value": "number"
            }
          ],
          "optional": false
        }
      ],
      "args": [
        {
          "def": "arg",
          "name": "n",
          "desc": "number to be shifted",
          "type": [
            {
              "def": "simple",
              "value": "number"
            }
          ],
          "variadic": false,
          "optional": false
        },
        {
          "def": "arg",
          "name": "i",
          "desc": "bits to shift by",
          "type": [
            {
              "def": "simple",
              "value": "number"
            }
          ],
          "variadic": false,
          "optional": false
        }
      ]
    }
  ],
  "desc": "Shifts `n` by `i` bits to the right (if `i` is negative, a left shift is performed instead).\nThe most significant bit of `n` is propagated during the shift.\nWhen `i` is larger than `31`, returns an integer with all bits set to the sign bit of `n`.\nWhen `i` is smaller than `-31`, `0` is returned",
  "link": "https://luau.org/library#bit32-library#:~:text=function%20bit32.arshift",
  "takesSelf": false,
  "private": false
}

< Back to bit32