Category:bit

From Garry's Mod
Revision as of 20:36, 14 May 2017 by JasonMan (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Examples

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

Pages in category "bit"

The following 12 pages are in this category, out of 12 total.

Personal tools
Navigation