Changeset View
Changeset View
Standalone View
Standalone View
src/wtf/MathExtras.h
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 82 | { | |||
---|---|---|---|---|---|
83 | return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); | 83 | return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); | ||
84 | } | 84 | } | ||
85 | inline bool signbit(double num) | 85 | inline bool signbit(double num) | ||
86 | { | 86 | { | ||
87 | return _copysign(1.0, num) < 0; | 87 | return _copysign(1.0, num) < 0; | ||
88 | } | 88 | } | ||
89 | #endif | 89 | #endif | ||
90 | 90 | | |||
91 | #if _MSC_VER < 1920 | ||||
91 | #ifndef BUILDING_KDE__ | 92 | #ifndef BUILDING_KDE__ | ||
92 | // FIXME: where to get std::numeric_limits from? | 93 | // FIXME: where to get std::numeric_limits from? | ||
93 | // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. | 94 | // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. | ||
94 | inline double wtf_atan2(double x, double y) | 95 | inline double wtf_atan2(double x, double y) | ||
95 | { | 96 | { | ||
96 | static double posInf = std::numeric_limits<double>::infinity(); | 97 | static double posInf = std::numeric_limits<double>::infinity(); | ||
97 | static double negInf = -std::numeric_limits<double>::infinity(); | 98 | static double negInf = -std::numeric_limits<double>::infinity(); | ||
98 | 99 | | |||
Show All 23 Lines | |||||
122 | inline double wtf_fmod(double x, double y) | 123 | inline double wtf_fmod(double x, double y) | ||
123 | { | 124 | { | ||
124 | return (!isinf(x) && isinf(y)) ? x : fmod(x, y); | 125 | return (!isinf(x) && isinf(y)) ? x : fmod(x, y); | ||
125 | } | 126 | } | ||
126 | 127 | | |||
127 | #define fmod(x, y) wtf_fmod(x, y) | 128 | #define fmod(x, y) wtf_fmod(x, y) | ||
128 | 129 | | |||
129 | #define atan2(x, y) wtf_atan2(x, y) | 130 | #define atan2(x, y) wtf_atan2(x, y) | ||
130 | 131 | #endif // _MSC_VER < 1920 | |||
131 | #endif // #if COMPILER(MSVC) | 132 | #endif // #if COMPILER(MSVC) | ||
132 | 133 | | |||
133 | inline double deg2rad(double d) | 134 | inline double deg2rad(double d) | ||
134 | { | 135 | { | ||
135 | return d * piDouble / 180.0; | 136 | return d * piDouble / 180.0; | ||
136 | } | 137 | } | ||
137 | inline double rad2deg(double r) | 138 | inline double rad2deg(double r) | ||
138 | { | 139 | { | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |