ComposeBinary()

Format

ComposeBinary(FirstBit [,SubsequentBits])

Returns

Returns the number which was built from the bits which were provided by the parameters.

Inputs

FirstBit: A collection of values which will determine the first bit of the returned number. This would be the least significant bit. The collection must contain exactly 1 value which must be either 0 or 1, depending on whether the bit should be set in the result.
Behaviour: Required
Dimensions: Collection, MultiCollection
Valid data types: Decimal, Integer

SubsequentBits: Collections of values which will determine the second and subsequent bits of the returned number. The collections must contain exactly 1 value which must be either 0 or 1, depending on whether the respective bit should be set in the result.
Behaviour: ParamsArray
Dimensions: Collection, MultiCollection
Valid data types: Decimal, Integer

Points to Note

  • The first input (e.g. Tag1) is the least significant bit, Tag2 is the next significant bit, etc.
  • The term "Tag" includes tags, calculations, attribute values, etc.
  • It is assumed that each Tag returns either 0 or 1.  A tag returning any other value will result in an error.
  • The function will reject all input values which don't contain exactly 1 value. 
  • Each tag is a bit of the binary number , which can subsequently be converted to a decimal.

Examples

Expression: ComposeBinary({tag1}, {tag2}, {tag3})
Result: If the value of tag1 is 0, the value of tag2 is 1, and the value of tag3 is 1, then the second and the third bits will be set for the returned number. This means that the result will be 110 in binary or 6 in the decimal (Base-10) number system.

Expression: ComposeBinary({tag1}, {tag2}, 0, 1, {tag3})
Result: Returns an error as the function is expecting all inputs to be tags. If the intention is to replace a tag with a static value, then calculations should be declared (such as {Zero} and {One}) that consist of the same single value. If the Raw sample method is to be used, then the calc should reference the sample method e.g. {zero, sampleMethod=raw}

Release History

  • ComposeBinary() 4.7.0
    • Initial version

Comments are closed