File indexing completed on 2024-05-12 04:20:35

0001 /*
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KCHARTMATH_P_H
0010 #define KCHARTMATH_P_H
0011 
0012 #if defined Q_OS_DARWIN
0013 #include <math.h>
0014 #endif
0015 
0016 #include <cmath>
0017 
0018 #ifdef Q_OS_SOLARIS
0019 #include <sunmath.h>
0020 #include <math.h>
0021 #endif
0022 
0023 #include <qglobal.h>
0024 
0025 #include <limits>
0026 
0027 #define NaN std::numeric_limits< qreal >::quiet_NaN()
0028 #define signalingNaN std::numeric_limits< qreal >::signaling_NaN()
0029 
0030 #ifndef M_PI
0031 #define M_PI 3.14159265358979323846
0032 #endif
0033 
0034 #define DEGTORAD(d) (d)*M_PI/180
0035 
0036 // We use our own ISNAN / ISINF in the code to detect
0037 // that we defined them.
0038 // reason: Windows does not have isnan() / isinf()
0039 #if defined (Q_OS_WIN)
0040 #include <float.h>
0041 #define ISNAN(x ) _isnan(x )
0042 #define ISINF(x ) (!(_finite(x ) + _isnan(x ) ) )
0043 #elif defined (Q_OS_DARWIN)
0044 // OS X does have isnan() & isinf() in math.h, but it appears to be
0045 // required to cast the argument to a double explicitly.
0046 #define ISNAN(x) isnan(double(x))
0047 #define ISINF(x) isinf(double(x))
0048 #elif defined (Q_OS_CYGWIN) || __cplusplus >= 201103L
0049 #define ISNAN(x) std::isnan(x)
0050 #define ISINF(x) std::isinf(x)
0051 #else
0052 #define ISNAN(x) isnan(x)
0053 #define ISINF(x) isinf(x)
0054 #endif
0055 
0056 #endif