File indexing completed on 2024-05-12 15:54:18

0001 /*
0002  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef KCHARTMATH_P_H
0021 #define KCHARTMATH_P_H
0022 
0023 #if defined Q_OS_DARWIN
0024 #include <math.h>
0025 #endif
0026 
0027 #include <cmath>
0028 
0029 #ifdef Q_OS_SOLARIS
0030 #include <sunmath.h>
0031 #include <math.h>
0032 #endif
0033 
0034 #include <qglobal.h>
0035 
0036 #include <limits>
0037 
0038 #define NaN std::numeric_limits< qreal >::quiet_NaN()
0039 #define signalingNaN std::numeric_limits< qreal >::signaling_NaN()
0040 
0041 #ifndef M_PI
0042 #define M_PI 3.14159265358979323846
0043 #endif
0044 
0045 #define DEGTORAD(d) (d)*M_PI/180
0046 
0047 // We use our own ISNAN / ISINF in the code to detect
0048 // that we defined them.
0049 // reason: Windows does not have isnan() / isinf()
0050 #if defined (Q_OS_WIN)
0051 #include <float.h>
0052 #define ISNAN(x ) _isnan(x )
0053 #define ISINF(x ) (!(_finite(x ) + _isnan(x ) ) )
0054 #elif defined (Q_OS_DARWIN)
0055 // OS X does have isnan() & isinf() in math.h, but it appears to be
0056 // required to cast the argument to a double explicitly.
0057 #define ISNAN(x) isnan(double(x))
0058 #define ISINF(x) isinf(double(x))
0059 #elif defined (Q_OS_CYGWIN) || __cplusplus >= 201103L
0060 #define ISNAN(x) std::isnan(x)
0061 #define ISINF(x) std::isinf(x)
0062 #else
0063 #define ISNAN(x) isnan(x)
0064 #define ISINF(x) isinf(x)
0065 #endif
0066 
0067 #endif