MeshLib
 
Loading...
Searching...
No Matches
MRIsNaN.h
Go to the documentation of this file.
1#pragma once
2
3#include <bit>
4#if defined( __GNUC__ ) && __GNUC__ < 11
5#include <cmath>
6#else
7#include <limits>
8#endif
9
10namespace MR
11{
12
13constexpr float cQuietNan = std::numeric_limits<float>::quiet_NaN();
14#if !defined( __GNUC__ ) || __GNUC__ >= 11
15constexpr int cQuietNanBits = std::bit_cast< int >( cQuietNan );
16#endif
17
19inline bool isNanFast( float f )
20{
21#if defined( __GNUC__ ) && __GNUC__ < 11
22 return std::isnan( f );
23#else
24 return std::bit_cast< int >( f ) == cQuietNanBits;
25#endif
26}
27
28} //namespace MR
Definition MRCameraOrientationPlugin.h:7
constexpr int cQuietNanBits
Definition MRIsNaN.h:15
constexpr float cQuietNan
Definition MRIsNaN.h:13
bool isNanFast(float f)
quickly tests whether given float is not-a-number
Definition MRIsNaN.h:19