目录

ScalarGetSFFValue

Function Description

Obtains the position where the first 0 or 1 appears in a binary number of the uint64_t type. The index starts from the least significant bit (index 0). If no 0 or 1 is found, -1 is returned. When the countValue parameter is set to 1, the position of the first 1 is searched for. When the countValue parameter is set to 0, the position of the first 0 is searched for. This function is often used in scenarios such as bit operation optimization and data compression algorithms to improve processing efficiency.

Function Prototype

template <int countValue>  
__aicore__ inline int64_t ScalarGetSFFValue(uint64_t valueIn)

Parameters

Table 1 Parameters

Parameter Input/Output Description
valueIn Input Input data of the uint64_t type.
countValue Input Location of the first 0 or 1. The data type is int, and the value is 0 or 1.

Return Value

Location of the first 0 or 1 in valueIn.

Supported Models

Kirin 9020 series processors

Kirin 9030 series processors

Kirin X90 series processors

Restrictions

None.

Calling Example

uint64_t valueIn = 28;
// Output (oneCount): 2
int64_t oneCount = AscendC::ScalarGetSFFValue<1>(valueIn);