binEnc
This function is used by Ignition's Expression language.
Description​
This function, whose name stands for "binary encoder", takes a list of booleans and treats them like the bits in a binary number. It returns an integer representing the decimal value of the number. The digits go from least significant to most significant.
Changed in 8.1.16
This function now enforces up to 64 max arguments. Note that 32 arguments or fewer will return an Integer and 33 arguments to 64 arguments will return a Long. More than 64 arguments will return an error.Syntax​
binEnc(value, [value, ...])
Parameters​
Type | Parameter | Description |
---|---|---|
Boolean | value | A value that represents a bit. Each argument can be either 0 or 1. Up to 64 arguments are allowed. |
Returns​
- Integer - The integer representation of the binary value when 32 or fewer arguments are provided.
- Long - The integer representation of the binary value when 33 to 64 arguments are provided.
Examples​
Code Snippet
binEnc(0,0,1,0) //returns 4 (the value of 0100)
Code Snippet
binEnc(true,0,1,1,0) //returns 13 (the value of 01101)