Garry's Mod Wiki

bit

The bitwise library contains useful functions for bitwise operations. Make sure you're familiar with Bitwise Operators

Example

Displays some bitwise operator functionality.

local mybits = 0 mybits = bit.bor(mybits, 2) -- Add 2 4 and 8 to mybits mybits = bit.bor(mybits, 4) mybits = bit.bor(mybits, 8) print(bit.band(mybits, 4) == 4) -- Does mybits have 4? mybits = bit.band(mybits, bit.bnot(4)) -- Remove 4 from mybits print(bit.band(mybits, 4) == 4) -- Does mybits have 4? print(bit.band(mybits, 2) == 2) -- Does mybits have 2?
Output:
true false true

Page Links


Special Pages


Wikis

?

Render Time: 42ms

DB GetPage 2
Generate Html 7
SaveChanges (1) 12
Render Body 0
Render Sidebar 19