1 /* 2 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 3 * 4 * This file is part of the KD Chart library. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef KCHARTMATH_P_H 21 #define KCHARTMATH_P_H 22 23 #if defined Q_OS_DARWIN 24 #include <math.h> 25 #endif 26 27 #include <cmath> 28 29 #ifdef Q_OS_SOLARIS 30 #include <sunmath.h> 31 #include <math.h> 32 #endif 33 34 #include <qglobal.h> 35 36 #include <limits> 37 38 #define NaN std::numeric_limits< qreal >::quiet_NaN() 39 #define signalingNaN std::numeric_limits< qreal >::signaling_NaN() 40 41 #ifndef M_PI 42 #define M_PI 3.14159265358979323846 43 #endif 44 45 #define DEGTORAD(d) (d)*M_PI/180 46 47 // We use our own ISNAN / ISINF in the code to detect 48 // that we defined them. 49 // reason: Windows does not have isnan() / isinf() 50 #if defined (Q_OS_WIN) 51 #include <float.h> 52 #define ISNAN(x ) _isnan(x ) 53 #define ISINF(x ) (!(_finite(x ) + _isnan(x ) ) ) 54 #elif defined (Q_OS_DARWIN) 55 // OS X does have isnan() & isinf() in math.h, but it appears to be 56 // required to cast the argument to a double explicitly. 57 #define ISNAN(x) isnan(double(x)) 58 #define ISINF(x) isinf(double(x)) 59 #elif defined (Q_OS_CYGWIN) || __cplusplus >= 201103L 60 #define ISNAN(x) std::isnan(x) 61 #define ISINF(x) std::isinf(x) 62 #else 63 #define ISNAN(x) isnan(x) 64 #define ISINF(x) isinf(x) 65 #endif 66 67 #endif 68