WTF
Go to the documentation of this file.
26 #ifndef WTF_MathExtras_h
27 #define WTF_MathExtras_h
33 #include "kjs/operations.h"
34 #include "kjs/value.h"
45 const double piDouble = 3.14159265358979323846;
46 const float piFloat = 3.14159265358979323846f;
49 const float piFloat =
static_cast<float>(M_PI);
58 #endif // !BUILDING_KDE__
62 #ifndef BUILDING_KDE__
63 inline bool isinf(
double num) {
return !_finite(num) && !_isnan(num); }
64 inline bool isnan(
double num) {
return _isnan(num); }
65 inline long lround(
double num) {
return num > 0 ? num + 0.5 : ceil(num - 0.5); }
66 inline long lroundf(
float num) {
return num > 0 ? num + 0.5f : ceilf(num - 0.5f); }
67 inline double round(
double num) {
return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
68 inline float roundf(
float num) {
return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
69 inline bool signbit(
double num) {
return _copysign(1.0, num) < 0; }
72 #ifndef BUILDING_KDE__
75 inline double wtf_atan2(
double x,
double y)
77 static double posInf = std::numeric_limits<double>::infinity();
78 static double negInf = -std::numeric_limits<double>::infinity();
80 double result = KJS::NaN;
82 if (x == posInf && y == posInf)
84 else if (x == posInf && y == negInf)
86 else if (x == negInf && y == posInf)
88 else if (x == negInf && y == negInf)
91 result = ::atan2(x, y);
95 #else // !BUILDING_KDE__
97 #define wtf_atan2(x, y) atan2(x, y)
99 #endif // !BUILDING_KDE__
104 inline double wtf_fmod(
double x,
double y) {
return (!isinf(x) && isinf(y)) ? x : fmod(x, y); }
106 #define fmod(x, y) wtf_fmod(x, y)
108 #endif // #if COMPILER(MSVC)
110 #define atan2(x, y) wtf_atan2(x, y)
112 #endif // #if PLATFORM(WIN)
116 inline double deg2grad(
double d) {
return d * 400.0 / 360.0; }
117 inline double grad2deg(
double g) {
return g * 360.0 / 400.0; }
123 inline float deg2grad(
float d) {
return d * 400.0f / 360.0f; }
124 inline float grad2deg(
float g) {
return g * 360.0f / 400.0f; }
128 #endif // #ifndef WTF_MathExtras_h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:46 by
doxygen 1.8.7 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.