bit32.countlz

bit32.countlz (n: number) -> number

Returns the number of consecutive zero bits in the 32-bit representation of n starting from the left-most (most significant) bit. Returns 32 if n is 0.

Example

bit32.countlz(3.14)
Raw function spec json
{
  "def": "func",
  "name": "countlz",
  "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": "",
          "type": [
            {
              "def": "simple",
              "value": "number"
            }
          ],
          "variadic": false,
          "optional": false
        }
      ]
    }
  ],
  "desc": "Returns the number of consecutive zero bits in the 32-bit representation of `n` starting from the left-most (most significant) bit.\nReturns `32` if `n` is `0`.",
  "link": "https://luau.org/library#bit32-library#:~:text=function%20bit32.countlz",
  "takesSelf": false,
  "private": false
}

< Back to bit32