isinf()
Anonymous contributor
Published Feb 3, 2023
Contribute to Docs
The isinf()
function returns a value indicating whether or not the argument is an infinite value.
Syntax
isinf(x)
The x
parameter is a floating-point value. If x
is infinite, the isinf()
function will return a non-zero value for true
. Otherwise, it will return zero for false
.
Examples of positive or negative infinite values include division by zero.
Example
The following example uses the isinf()
function to check whether 1.0
is infinite:
#include <iostream>#include <cmath>int main() {int result;result = std::isinf(1.0);if (result == 0) {std::cout << "Not infinite" << "\n";}else {std::cout << "Is infinite" << "\n";}}
This produces the following output:
Not infinite
Codebyte Example
The following example is runnable and prints a message based on whether the isinf()
function indicates a given value is finite or infinite:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C++
Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.Beginner Friendly11 hours