C++ Standard Library C++ STL Library

C++ <cmath> - isnormal() Function

The C++ <cmath> isnormal() function returns true if the given argument is a normal value, else returns false. A normal value is any floating-point value that is neither infinity, NaN, zero or subnormal.


bool isnormal (float x);
bool isnormal (double x);
bool isnormal (long double x);               


x Specify a floating-point value.

Return Value

Returns true (non-zero value) if the argument is an infinity value, else returns false (zero value).


The example below shows the usage of isnormal() function.

#include <iostream>
#include <cmath>

using namespace std;
int main (){

  cout<<"isnormal(10.5): "<<isnormal(10.5)<<"\n";
  cout<<"isnormal(1.0/0.0): "<<isnormal(1.0/0.0)<<"\n";
  cout<<"isnormal(0.0/0.0): "<<isnormal(0.0/0.0)<<"\n";
  cout<<"isnormal(sqrt(-1.0)): "<<isnormal(sqrt(-1.0))<<"\n";
  return 0;

The output of the above code will be:

isnormal(10.5): true
isnormal(1.0/0.0): false
isnormal(0.0/0.0): false
isnormal(sqrt(-1.0)): false

❮ C++ <cmath> Library