Libraries.Compute.BitwiseOperations Documentation

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)

Inherits from: Libraries.Language.Object

Actions Documentation

And(integer left, integer right)

This action provides a bitwise and operation.

Parameters

  • integer left
  • integer right

Return

integer:

Example



use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

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

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

ExclusiveOr(integer left, integer right)

This action provides a bitwise exclusive or operation.

Parameters

  • integer left
  • integer right

Return

integer:

Example



use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

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

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

Negate(integer value)

This action provides a bitwise negate operation.

Parameters

  • integer value

Return

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

  • integer left
  • integer right

Return

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

  • integer value
  • integer amount

Return

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

  • integer value
  • integer amount

Return

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

  • integer value
  • integer amount

Return

integer:

Example



use Libraries.Compute.BitwiseOperations
BitwiseOperations ops

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