GetBit
- Last UpdatedAug 14, 2026
- 1 minute read
GetBit returns a specific bit in the value of a project tag.
|
Group |
Sync / Async Exec |
String Exp? |
Windows Support |
Windows Embedded Support |
IoT View Support |
Thin Client Support |
Mobile Access Support |
|
Arithmetic |
Sync |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Syntax
GetBit("tagName", numBitNumber)
tagName
The name of the project tag.
Note: If this parameter is enclosed in quotes, the string literal will be used. Otherwise, the value of the tag/expression will be used.
numBitNumber
The number or position (a number from 0 to 31) of the bit.
Return value
If successful, this function returns the value (either 0 or 1) of the specified bit.
If unsuccessful, this function returns one of the following values:
|
Value |
Description |
|---|---|
|
-2 |
Specified tag does not exist. |
Notes
You can also reference the Bit property of a project tag in order to get/set a specific bit in the value of that tag. For more information, see Reference a tag property instead of a project tag.
Examples
Get the bit in the fifth position (the fourth bit) of MyInteger:
GetBit("MyInteger",4)
If the value of MyInteger is 14, the function returns 0. If the value of MyInteger is 19, the function returns 1.