This function is defined in <cmath.h> .The isinf() function is use to determine whether the given number is infinity or not i.e positive infinity or negative infinity both. This function returns 1 if the given number is infinite otherwise this function returns zero.
bool isinf( float arg );
bool isinf( double arg );
bool isinf( long double arg );
Parameter: This function takes a mandatory parameter x which represents the given floating point value.
Return: This function returns 1 if the given number is infinite else return zero.
Below programs illustrate the isinf() function in C++:
Example 1:- To show infinite case which returns 1
isinf(6.0/0.0) is = 1 isinf(-1.2/0.0) is = 1
Explanation: In example 1 the floating point number represents infinity that’s why function returns 1.
Example 2:- To show non-infinite case which returns 0
isinf(0.0) is = 0 isinf(sqrt(-1.0)) is = 0
Exception: In example 2 the given floating point number is not representing infinity that’s why function returns zero.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- What happens when a virtual function is called inside a non-virtual function in C++
- Function Overloading vs Function Overriding in C++
- Difference between Virtual function and Pure virtual function in C++
- How to call function within function in C or C++
- Difference between virtual function and inline function in C++
- Can we call an undeclared function in C++?
- Can we use function on left side of an expression in C and C++?
- Declare a C/C++ function returning pointer to array of integer pointers
- Function overloading and return type
- Default arguments and virtual function
- Function overloading and const keyword
- How to measure time taken by a function in C?
- Comparator function of qsort() in C
- Can we access private data members of a class without using a member or a friend function?
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
- A C/C++ Function Call Puzzle
- std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++
- Bind function and placeholders in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.