Bitwise Operations¶
bitand¶
Syntax
bitand(x,y)
bitand(x,y,assumedType)
Description
Performs the logical AND operation on each pair of corresponding bits
of x and y. If x or y is an array, then it will
perform the logical AND operation of each pair of elements.
- The function expects that the length of all input arrays to be
equal. It will expand any scalar inputs to the appropriately
sized array before performing
bitandof each element. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before computing the logical AND operation. - If
assumedTypeis provided, it identifies the type for the inputsxandyas either fixed width signed or fixed width unsigned integers. It must have the form'intN'or'uintN'whereNis a positive integer.
bitcmp¶
Syntax
bitcmp(x)
bitcmp(x,assumedType)
Description
Performs the bitwise complement of the operand. The input may be
singular or an array of numerical or logical values. If x is an
array, it computes bitcmp for each element in x.
- If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before computing the complement. - If
assumedTypeis provided, it identifies the type for the inputxas either a fixed width signed or fixed width unsigned integer. It must have the form'intN'or'uintN'whereNis a positive integer.
bitor¶
Syntax
bitor(x,y)
bitor(x,y,assumedType)
Description
Performs the logical OR operation on each pair of corresponding bits
of x and y. If x or y is an array, then it will
perform the logical OR operation of each pair of elements.
- The function expects that the length of all input arrays to be
equal. It will expand any scalar inputs to the appropriately
sized array before performing
bitorof each element. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before computing the logical OR operation. - If
assumedTypeis provided, it identifies the type for the inputsxandyas either fixed width signed or fixed width unsigned integers. It must have the form'intN'or'uintN'whereNis a positive integer.
bitget¶
Syntax
bitget(x,bitPosition)
bitget(x,bitPosition,assumedType)
Description
Returns the bit value of x at location bitPosition. The
bitPosition must be a positive integer between 1 and the number of
bits in the integer class of x. The bitPosition may be an
integer array, in which case, this function returns the bit values of
x and each location identified in the array bitPosition.
- If
xis an array, it returns the bit value at positionbitPositionfor each element inx. IfbitPositionis an array, its length must agree with the length ofx. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before retrieving any bit values. - If
assumedTypeis provided, it identifies the type for the inputxas either a fixed width signed or fixed width unsigned integer. It must have the form'intN'or'uintN'whereNis a positive integer.
bitset¶
Syntax
bitset(x,bitPosition,val)
bitset(x,bitPosition,val,assumedType)
Description
Returns x with the bit at location bitPosition set to val.
If x is an array, it returns an array where each element of x
has the bitPosition set to val. The bitPosition must be a
positive integer between 1 and the number of bits in the integer class
of x.
- The operand
bitPositionmay also be an integer array. Note thatvalmay be a scalar or numeric array, however,valwill be converted to logical array before it is used to set bits inx. - The function expects that the length of all input arrays to be
equal. It will expand any scalar inputs to the appropriately
sized array before performing
bitsetof each element. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before setting any bits. - If
assumedTypeis provided, it identifies the type for the inputxas either a fixed width signed or fixed width unsigned integer. It must have the form'intN'or'uintN'whereNis a positive integer.
bitshift¶
Syntax
bitshift(x,n)
bitshift(x,n,assumedType)
Description
When n is positive integer, return x shifted to the left by
n bits. This is equivalent to multiplying x by 2^n. When
n is negative, return x shifted to the right by n
bits. This is equivalent to dividing by 2^n and rounding to the
nearest integer less than or equal to the result. Any overflow bits
are truncated.
- When
xis real, Grackle will convert the operand to an unsigned 64bit integer before performing the shift operation. Negative real values forxare not permitted. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before shifting any bits. - If
assumedTypeis provided, it identifies the type for the inputxas either a fixed width signed or fixed width unsigned integer. It must have the form'intN'or'uintN'whereNis a positive integer.
bitxor¶
Syntax
bitxor(x,y)
bitxor(x,y,assumedType)
Description
Performs the logical exclusive OR operation on each pair of
corresponding bits of the operands. If x or y is an array,
then it will perform the logical XOR operation of each pair of
elements.
- The function expects that the length of all input arrays to be
equal. It will expand any scalar inputs to the appropriately
sized array before performing
bitxorof each element. - If
assumedTypeis not provided, Grackle will implicitly convert real inputs to 64bit unsigned integers before computing the logical XOR operation. - If
assumedTypeis provided, it identifies the type for the inputsxandyas either fixed width signed or fixed width unsigned integers. It must have the form'intN'or'uintN'whereNis a positive integer.