bitwiseand: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
(Removed spam link.)
Line 2: Line 2:
|name=bitwiseand
|name=bitwiseand
|description=Performs a bitwise 'and' operation of the {number} arguments by taking the binary representation of each of the numbers and performing the logical and operation on each of the bits.
|description=Performs a bitwise 'and' operation of the {number} arguments by taking the binary representation of each of the numbers and performing the logical and operation on each of the bits.
[http://www.superiorpapers.com/ custom paper]


'''Logical "and" Table'''
'''Logical "and" Table'''

Revision as of 13:18, 28 July 2010

bitwiseand() Function

Performs a bitwise 'and' operation of the {number} arguments by taking the binary representation of each of the numbers and performing the logical and operation on each of the bits.

Logical "and" Table

Bit1 Bit2 Result
0 0 0
0 1 0
1 1 1

Usage

[h: val = band(num, num, ...)]
[h: val = bitwiseand(num, num, ...)]

Examples

[r: band(1,0)]

Returns 0.

[r: band(1,1)]

Returns 1.

[r: band(3, 5]

Returns 1. 3 in binary is 011 and 5 in binary is 101, the bitwise 'and' of these values is 001 in binary which is 1 in decimal.

[r: band(20, 12)]

Returns 4.

20 in binary is 10100 and 12 in binary is 01100, the bitwise 'and' of these values is 00100 in binary which is 4 in decimal.