File indexing completed on 2024-05-12 11:53:05
0001 /* 0002 Approximated math functions used into conversions. 0003 0004 SPDX-FileCopyrightText: Edward Kmett 0005 SPDX-FileCopyrightText: 2023 Mirco Miranda <mircomir@outlook.com> 0006 0007 SPDX-License-Identifier: BSD-3-Clause 0008 */ 0009 #ifndef FASTMATH_P_H 0010 #define FASTMATH_P_H 0011 0012 #include <QtGlobal> 0013 0014 /*! 0015 * \brief fastPow 0016 * Based on Edward Kmett code released into the public domain. 0017 * See also: https://github.com/ekmett/approximate 0018 */ 0019 inline double fastPow(double x, double y) 0020 { 0021 union { 0022 double d; 0023 qint32 i[2]; 0024 } u = {x}; 0025 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN 0026 u.i[1] = qint32(y * (u.i[1] - 1072632447) + 1072632447); 0027 u.i[0] = 0; 0028 #else // never tested 0029 u.i[0] = qint32(y * (u.i[0] - 1072632447) + 1072632447); 0030 u.i[1] = 0; 0031 #endif 0032 return u.d; 0033 } 0034 0035 #endif // FASTMATH_P_H