Isnormal
Defined in header <cmath>
.
Description
Determines if the given floating point number num
is normal
, i.e. is neither zero
, subnormal
, infinite
, nor NaN
.
The library provides overloads for all cv-unqualified floating-point types as the type of the parameter num
(od C++23).
Additional Overloads are provided for all integer types, which are treated as double.
Declarations
- C++23
- C++11
// 1)
constexpr bool isnormal( /* floating-point-type */ num );
// 2)
template< class Integer >
constexpr bool isnormal( Integer num );
// 1)
bool isnormal( float num );
// 2)
bool isnormal( double num );
// 3)
bool isnormal( long double num );
// 4)
template< class Integer >
bool isnormal( Integer num );
Parameters
num
- floating-point or integer value
Return value
true
if num
is normal
, false
otherwise.
Notes
The additional overloads are not required to be provided exactly as Additional Overloads.
They only need to be sufficient to ensure that for their argument num of integer type,
std::isnormal(num)
has the same effect as std::isnormal(static_cast<double>(num))
.
Examples
#include <cfloat>
#include <cmath>
#include <iostream>
int main()
{
std::cout
<< std::boolalpha
<< "isnormal(NaN) = "
<< std::isnormal(NAN) << '\n'
<< "isnormal(Inf) = "
<< std::isnormal(INFINITY) << '\n'
<< "isnormal(0.0) = "
<< std::isnormal(0.0) << '\n'
<< "isnormal(DBL_MIN/2.0) = "
<< std::isnormal(DBL_MIN / 2.0) << '\n'
<< "isnormal(1.0) = "
<< std::isnormal(1.0) << '\n';
}
isnormal(NaN) = false
isnormal(Inf) = false
isnormal(0.0) = false
isnormal(DBL_MIN/2.0) = false
isnormal(1.0) = true