BITCOUNT function: Return type and negative-integer behavior at GA (Pending)

Attention

This behavior change is in the 2026_07 bundle.

For the current status of the bundle, refer to Bundle history.

The BITCOUNT function, which counts the number of set bits in its argument, is reaching general availability. Although the function has been reachable in production since 2020, it hasn’t been publicly documented until now. Two aspects of its behavior that were previously unspecified are now pinned down, which changes the results returned to existing callers.

Before the change:

BITCOUNT behaved as follows:

  • The return type mirrored the integer width of the argument.
  • For a negative integer argument, set bits were counted over the argument’s own native width. For example, BITCOUNT(-1::NUMBER(2,0)) returned 8.
After the change:

BITCOUNT behaves as follows:

  • The return type is a fixed BIGINT, regardless of the argument’s integer width.
  • For a negative integer argument, the value is sign-extended to 128 bits before its set bits are counted. For example, BITCOUNT(-1::NUMBER(2,0)) now returns 128.

Support for BINARY and VARBINARY arguments is also added. This is net-new capability and doesn’t affect existing callers.

This change is being made to give BITCOUNT a stable, well-defined contract at general availability: a single return type across all integer widths, and consistent handling of negative values based on their full signed representation.

Ref: 2417