isnormal() in C++


In this section we will see the isnormal() function in C++. This function is present in the cmath library. This function is used to check whether a number is normal or not. The numbers that are considered as non-normal are zeros, infinity or NAN.

This function takes float, double or long double values as argument. Returns 1 if the number is normal, otherwise returns 0.

Example

 Live Demo

#include<iostream>
#include<cmath>
using namespace std;
int main() {
   cout << "isnormal(" << 5.23 << "): " << isnormal(5.23) << endl;
   cout << "isnormal(" << 0.00 << "): " << isnormal(0.00) << endl;
   cout << "isnormal(" << 2.0/0.0 << "): " << isnormal(2.0/0.0) << endl;
}

Output

isnormal(5.23): 1
isnormal(0): 0
isnormal(inf): 0

Updated on: 30-Jul-2019

65 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements