1lytics

Operations on input vector

  • gkGetBit - returns one bit from taken input bit vector from specified position
  • gkGetBits - returns a taken number of bits from taken input bit vector from specified position
  • gkGetOnesCount - returns number of 1s in taken input bits vector
  • gkGetInputValue - returns an input value for specified input vector

gkGetBit

The gkGetBit function returns one bit from taken input bit vector from specified position. Bits counted from least significant bit to most (right-to-left).

InputValue = gkGetBit( InputVector, BitNo )

Parameters

  • InputVector - input values vector;
  • BitNo - bit number;

gkGetBits

The gkGetBits function returns a taken number of bits from taken input bit vector from specified position. Bits counted from least significant bit to most (right-to-left). Returned value aligned to right (see sample).

Bits = gkGetBits( InputVector, LessBitNo, NumBits )

Parameters

  • InputVector - input values vector;
  • LessBitNo - less signuficant bit number;
  • BitNo - bit number.

Usage sample

InputVector = 93 -- 0x5D or 01011101 binary
-- 4 bits starting from bint No 3
Bits = gkGetBits( InputVector, 3, 4 )
-- Displays 11 (0xB or 1011 binary) - (00{1011}101)
gkMessageBox("info", 'Bits: ' .. Bits)

gkGetOnesCount

The gkGetOnesCount function returns number of 1s in taken input bits vector.

NumberOfOnes = gkGetOnesCount(InputVector)

Parameters

  • InputVector - input values vector.

Usage sample

InputVector = 93 -- 0x5D or 01011101 binary
NumberOfOnes = gkGetOnesCount(InputVector)
gkMessageBox("info", 'Number of 1s: ' .. NumberOfOnes)

gkGetInputValue

The gkGetInputValue function returns an input value for specified input vector. Function works like gkGetBit but second parameter can be variable name or variable index from left-to-right, opposite to gkGetBit, which get bit number in order from right to left.

InputVal = gkGetInputValue( InputVector, VarNameOrIndex )

Parameters

  • InputVector - input values vector;
  • VarNameOrIndex - input variable name or index from left to right.