# LGF_BitCount (FC / 3.0.2)

Overview

Author: SiemensSIMATICSystemsSupport

## Short description

This block counts in a variable of type DWord how many bits are set (TRUE) and how many are not set (FALSE) and outputs the number at the outputs.
Instead of DWord, Word and Byte can also be used by converting the past parameter with e.g. BYTE_TO_DWORD and connecting the corresponding bit length of the data type at the parameter "numberOfBits".
Byte=8, Word=16, DWord=32

### Block Interface

| LGF_BitCount (FC) |
--- | --- | ---
DWord |  |  | value |  | Ret_Val |  |  | Void
USInt |  |  | numberOfBits |  | countBitsFalse |  |  | USInt
|  |  |  |  | countBitsTrue |  |  | USInt

### Input parameter

Identifier | Data type | Description
--- | --- | ---
value | DWord | Tag where the bit states has to be counted
numberOfBits | USInt | Number of bits in input tag "value" (bit size of Datatype), in case of Byte=8, Word=16, DWord=32

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Void | Void - Function has no return value
countBitsFalse | USInt | Number of bits are FALSE in input tag "value"
countBitsTrue | USInt | Number of bits are TRUE in input tag "value"

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Support
| 06.06.2015 | first release
| 3.0.0 | Siemens Industry Support
| 23.04.2020 | Set version to V3.0.0 harmonize the version of the whole library
| 3.0.2 | Simatic Systems Support
| 19.01.2021 | Insert documentation