Builtin functions of GCC compilerWhat is GCC compiler?GCC stands for GNU Compiler Collection, which is the collection of compilers which is generally used in C or C++ programs to convert the code into assembly language. We have a lot of inbuilt functions provided by the GCC, which are as follows: 1. __builtin_popcount()This function is used to return the number of set bits or number of 1s in a decimal number. It takes one argument as a decimal number and returns the number of 1s presented in it. As we know, we can represent any decimal number in binary format, representing a series of 1s and 0s. For example: int a = 12; We can represent 12 as 1100 in the binary format, so the number of 1's in the given integer is 2. C Example: Output: Note: We can use this function for long and long long data types, but the function name will be slightly changed.For long datatype: __builtin_popcountl() For long long data type: __builtin_popcountll() C Example: Output: 2. __builtin_parity()This function is used to determine the parity of a number. Parity means the number of set bits is even or odd. So if the number of set bits is odd, then it will return true or return one. Else, it will return false or return 0. For example: int num=12; In the above example, we can represent 12 in binary format as 1100, so it has 2 number of set bits, so for this example, the above function will give output as 0. Example: int num=13; We can represent 13 in binary format as 1101, so it has 3 number of set bits, which is odd, and this function will return 1. C Example: Output: Note: We can use this function for long and long long data types: |