Data connectivity & integrationPipeline Builder ExpressionsBit count

Bit count

Supported in: Batch, Faster, Streaming

Counts the bits set in an integral or boolean value. Integral values are widened to longs first, so a negative value also counts its sign extension. True counts as 1 and false as 0.

Expression categories: Binary

Declared arguments

  • Expression: The value whose set bits to count.
    Expression<Boolean | Byte | Integer | Long | Short>

Output type: Integer

Examples

Example 1: Base case

Description: A negative integer counts the 32 extra bits of its sign extension to a long.

Argument values:

  • Expression: value
valueOutput
73
00
-164

Example 2: Base case

Description: A boolean counts as 1 if true and 0 if false.

Argument values:

  • Expression: value
valueOutput
true1
false0

Example 3: Null case

Argument values:

  • Expression: value
valueOutput
nullnull