bit32.replace (n: number, r: number, f: number, w: number?) -> number
Replaces bits of n at position f and width w with r, and returns the resulting integer.
w defaults to 1, so a three-argument version of replace changes one bit at position f to r (which should be 0 or 1) and returns the result.
Bits are indexed starting at 0.
Errors if f and f+w-1 are not between 0 and 31.
bit32.replace(
3.14,
3.14,
3.14,
3.14
)
{
"def": "func",
"name": "replace",
"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
},
{
"def": "arg",
"name": "r",
"desc": "",
"type": [
{
"def": "simple",
"value": "number"
}
],
"variadic": false,
"optional": false
},
{
"def": "arg",
"name": "f",
"desc": "",
"type": [
{
"def": "simple",
"value": "number"
}
],
"variadic": false,
"optional": false
},
{
"def": "arg",
"name": "w",
"desc": "",
"type": [
{
"def": "simple",
"value": "number"
}
],
"variadic": false,
"optional": true
}
]
}
],
"desc": "Replaces bits of `n` at position `f` and width `w` with `r`, and returns the resulting integer.\n`w` defaults to `1`, so a three-argument version of replace changes one bit at position `f` to `r` (which should be `0` or `1`) and returns the result.\nBits are indexed starting at `0`.\nErrors if `f` and `f+w-1` are not between `0` and `31`.",
"link": "https://luau.org/library#bit32-library#:~:text=function%20bit32.replace",
"takesSelf": false,
"private": false
}