BitwiseOperations

Package: Libraries.Compute · Inherits from: Libraries.Language.Object

The BitwiseOperations class provides a way for a programmer to conduct bitwise operations on integer values. Common operations include bitwise and, bitwise or, shift operators, exclusive or, and negation. While these operators are provided for convenience, it should be noted that conducting bitwise operations in Quorum is slightly slower than conducting similar operations in other programming languages, due to the fact that such operations are conducted as system functions here. This makes the meaning of the calls more obvious than traditional, but makes them pass through the system plugin architecture, which makes several function calls.

Example Code

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer left = 10
integer right = 25
integer result = ops:And(left, right)

Actions

And(integer left, integer right)

This action provides a bitwise and operation.

Parameters

  • left integer
  • right integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer left = 10
integer right = 25
integer result = ops:And(left, right)

ExclusiveOr(integer left, integer right)

This action provides a bitwise exclusive or operation.

Parameters

  • left integer
  • right integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer left = 10
integer right = 25
integer result = ops:ExclusiveOr(left, right)

Negate(integer value)

This action provides a bitwise negate operation.

Parameters

  • value integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer value = 10
integer result = ops:Negate(value)

Or(integer left, integer right)

This action provides a bitwise or operation.

Parameters

  • left integer
  • right integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer left = 10
integer right = 25
integer result = ops:Or(left, right)

ShiftLeft(integer value, integer amount)

This action provides a bitwise shift left operation, shifting in zeros from the right and discarding the bits shifted off.

Parameters

  • value integer
  • amount integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer value = 10
integer amount = 3
integer result = ops:ShiftLeft(value, amount)

ShiftRight(integer value, integer amount)

This action provides a bitwise shift right operation. This version of the operation keeps the sign bit on the left (Sign-propogating right shift) and discards the bits shifted off.

Parameters

  • value integer
  • amount integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer value = 10
integer amount = 3
integer result = ops:ShiftRight(value, amount)

ShiftRightPositive(integer value, integer amount)

This action provides a bitwise shift right operation. This version shifts in zeros from the left (Zero-fill right shift) and discards the bits shifted off.

Parameters

  • value integer
  • amount integer

Returns

integer

Example

use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

integer value = 10
integer amount = 3
integer result = ops:ShiftRightKeepSign(value, amount)

Inherited Actions

3 actions from Libraries.Language.Object