Garry's Mod Wiki

Garry's Mod Wiki

  number bit.band( number value, ... )

Description

Performs the bitwise and for all values specified.

Arguments

1 number value
The value to be manipulated.
2 vararg ...
Values bit to perform bitwise "and" with. Optional.

Returns

1 number
Result of bitwise "and" operation.

Example

local a = 170 -- 10101010 in binary form local b = 146 -- 10010010 in binary form print( bit.band( a, b ) )
Output: 130 (10000010 in binary form)

Example

Tests for a specific damage type.

local myDamage = bit.bor( DMG_BULLET, DMG_RADIATION ) local isBulletDamage = bit.band( myDamage, DMG_BULLET ) == DMG_BULLET print( isBulletDamage )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...