![]() |
VOOZH | about |
These functions do not need to include any header file to use them. So it provides faster usage, as these are Built-in functions of GCC compiler which is most used compiler, even in competitive programming.
Note: If the compiler shows warning of overflow, use casting before __builtin_inf() function as
(data_type)__builtin_inf()
1. __builtin_inf(void): This function returns positive infinity which will then be converted to DBL_MAX of C language limits.h header file Macro. Its return data type is double.
Example:
if __builtin_inf() is used it returns infinite Output: inf
Here is a C++ program that shows the use of this function:
inf
2. __builtin_infd32(void): This function returns maximum value of 4-byte integer and returns data type is 32-bit integer.
Example:
if __builtin_infd32() is used it returns the maximum value of the 32-bit integer Output: 2147483647
Here is a C++ program which shows the use of this function:
2147483647 2147483647 4294967295 4294967295
3. __builtin_infd64(void): This function returns Highest value that can be represented by 8 byte integer which is highest value of integer we can use in C++.
Example:
if __builtin_infd64() is used it returns the maximum value of the 64-bit integer Output: 9223372036854775807
Here is a C++ program which shows the use of this function:
9223372036854775807 9223372036854775807 18446744073709551615 18446744073709551615
4. __builtin_infd128(void): As the maximum size that can be used for integer is 64-bit in C/C++, this function give the same result as __builtin_infd64().
Example:
if __builtin_infd128() is used it returns the maximum value of the 64-bit integer Output: 9223372036854775807
5. __builtin_inff(void): This function returns float maximum value means 4-byte maximum decimal point value.
Example:
if __builtin_inff() is used it returns the maximum value of the 32-bit float Output: inf
Here is a C++ program which shows the use of this function:
inf inf
6. __builtin_infl(void): This function returns maximum long double data type value.
Example:
if __builtin_infl() is used it returns the maximum value of the long double type Output: inf
Here is a C++ program which shows the use of this function:
inf inf
7. In the recent versions of GCC compiler, these are two new functions: __builtin_infn(void) & __builtin_infnx(void). One can replace n with 32 or 64 and it will return inf value respectively of 32-bit, 64-bit.
Similar article: Builtin functions of GCC compiler