CountBitsCntSameAsSignBit

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Computes the number of consecutive bits that are the same as the sign bit from the most significant bit in the binary number of the int64_t type.

If the input is -1 (all bits are 1) or 0 (all bits are 0), -1 is returned.

Prototype

1
__aicore__ inline int64_t CountBitsCntSameAsSignBit(int64_t valueIn)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

valueIn

Input

Input data of the int64_t type.

Returns

The number of consecutive bits that are the same as the sign bit starting from the most significant bit.

Constraints

None

Example

1
2
3
int64_t valueIn = 0x0f00000000000000;
// Output (ans): 3. The sign bit is 0, and the fourth bit is 1. Therefore, the number of bits that are the same as the most significant bit is 3.
int64_t ans = AscendC::CountBitsCntSameAsSignBit(valueIn);