Bitwise operators can be used to manipulate values for comparisons and calculations.
bitwiseAnd
Returns the result of doing the bitwiseAnd
operation on all values. Used in the following format, where value
must be one or more single digit number(s):
bitwiseAnd({value}+)
The return value type is an integer or long integer, depending on the parameters.
Examples
bitwiseAnd(true,3,2) # value: 2
bitwiseLeftShift
Returns a value shifted by a given number of counts to the left. Used in the following format, where value
must be one or more single digit number(s) and count
must be an integer:
bitwiseLeftShift(value,count)
The return value type is an integer or long integer, depending on the parameters.
Examples
bitwiseLeftShift(1,3) # value: 8
bitwiseNot
Returns the result of performing the bitwiseNot
operation on a given value.
Used in the following format, where value
must be one or more single digit number(s):
bitwiseNot(value)
The return value type is an integer or long integer, depending on the parameters.
Examples
bitwiseNot(3) # value: -4
bitwiseOr
Returns the result of doing the bitwiseOr
operation on all values. Used in the following format, where value
must be one or more single digit number(s):
bitwiseOr({value}+)
The return value type is an integer or long integer, depending on the parameters.
Examples
bitwiseOr(3,2) # value: 3
bitwiseRightShift
Returns a value shifted by a given number of counts to the right. Used in the following format, where value
must be one or more single digit number(s) and count
must be an integer:
bitwiseRightShift(value,count)
The return value type is an integer or long integer, depending on parameters.
Examples
bitwiseRightShift(8,3) # value: 1
bitwiseXor
Returns the result of doing the bitwiseXor
operation on all values. Used in the following format, where value
must be a numeric data type (not double):
bitwiseXor({value}+)
The return value type is an integer or long integer, depending on the parameters.
Examples
bitwiseXor(3,2) # value: 1
getBit
Indicates whether the index
'th bit is set (0 or 1). Used in the following format, where value
must be a numeric data type (not double) and index
must be an integer:
getBit(value,index)
The return value type is an integer or long integer, depending on the parameters.
Examples
getBit(5,0) # value: 1
getBit(5,1) # value: 0
getBit(5,2) # value: 1
setBit
Returns the result of setting the index
'th bit in value
to on
. Used in the following format, where value
must be a numeric data type (not double), index
must be an integer and on
indicates whether bit is 0 or 1:
setBit(value,index,on)
The return value type is an integer or long integer, depending on the parameters.
Examples
setBit(5,1,true) # value: 7
setBit(5,2,false) # value: 1