1/*
2 Approximated math functions used into conversions.
3
4 SPDX-FileCopyrightText: Edward Kmett
5 SPDX-FileCopyrightText: 2023 Mirco Miranda <mircomir@outlook.com>
6
7 SPDX-License-Identifier: BSD-3-Clause
8*/
9#ifndef FASTMATH_P_H
10#define FASTMATH_P_H
11
12#include <QtGlobal>
13
14/*!
15 * \brief fastPow
16 * Based on Edward Kmett code released into the public domain.
17 * See also: https://github.com/ekmett/approximate
18 */
19inline double fastPow(double x, double y)
20{
21 union {
22 double d;
23 qint32 i[2];
24 } u = {.d: x};
25#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
26 u.i[1] = qint32(y * (u.i[1] - 1072632447) + 1072632447);
27 u.i[0] = 0;
28#else // never tested
29 u.i[0] = qint32(y * (u.i[0] - 1072632447) + 1072632447);
30 u.i[1] = 0;
31#endif
32 return u.d;
33}
34
35#endif // FASTMATH_P_H
36

source code of kimageformats/src/imageformats/fastmath_p.h