isinf()
Anonymous contributor
Anonymous contributor5 total contributions
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 contributorAnonymous contributor5 total contributions
- Anonymous contributor
Looking to contribute?
- 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.