![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
isinf() function in C++
In this article we will be discussing the isinf() function in C++, its syntax, working and what will be its return value.
isinf() is an inbuilt function in C++ which comes under header file, the function is used to check whether the variable passed in it is infinity or not, no matter if the number is negative infinity or positive infinity. If the number is infinite the function returns a non-zero value (true) and if it is not then it passes zero (false). Also if the number is NAN then also the function will return 0.
Syntax
bool isinf(float n);
or
bool isinf(double n);
or
bool isinf(long double n);
This function accepts only one floating point number.
Return value
Function returns boolean value, 0 for false(not infinity) and 1 if it is true(infinite).
Example
#include <iostream> #include <cmath> using namespace std; int main() { float a = 0.0, b = 10.0; isinf(a/b)?cout<<"\nInfinte":cout<<"\nFinite"; //check the number is infinte or finite isinf(b/a)?cout<<"\nInfinite":cout<<"\nFinite"; }
Output
If we run the above code it will generate the following output −
Finite Infinite
Example
#include <iostream> #include <cmath> using namespace std; int main() { float a = 0.0; cout<<isinf(a); cout<<isinf(sqrt(-1.0)); }
Output
If we run the above code it will generate the following output −
0 0