# Band()

## Description

FUNCTION: **band**(*number*[, *number*[, ...]])

Arguments must be an integer and are treated as a bitfield. It performs a bitwise logical AND between these two bitfields and returns the resulting bitfield as an integer which can be further treated as an integer, a bitfield, or a logical boolean depending on your intentions.

- > think band(922,785)
- 784

In the above example, 922 in base 10 is equivalent to 39A in base 16 or 0011 1001 1010 in base 2. Likewise, 785 in base 10 is the same as 311 in base 16 and or 0011 0001 0001 in base 2.

- 0011 1001 1010 (922)
- (BAND)
- 0011 0001 0001 (785)
- --------------
- 0011 0001 0000 (784)

The result may be expressed as 310 in base 16 or 784 in base 10.

So, this function is useful for testing whether a particular bit in the field is 'on' or 'off'. More than one bit can be tested at a time. If all bits are 'off', the result is zero which can also be interpreted as a boolean false in softcode.

Related Topics: shl(), shr(), bnand(), bor(), bxor().

(Modified the example to display a bit more coherently. Non-monospace fonts are stinky! --Soylent 00:35, 3 December 2005 (EST))