Add a wxRound() overload for float
This commit is contained in:
@@ -62,14 +62,6 @@
|
|||||||
|
|
||||||
#define wxFinite(x) std::isfinite(x)
|
#define wxFinite(x) std::isfinite(x)
|
||||||
#define wxIsNaN(x) std::isnan(x)
|
#define wxIsNaN(x) std::isnan(x)
|
||||||
|
|
||||||
inline int wxRound(double x)
|
|
||||||
{
|
|
||||||
wxASSERT_MSG(x > (double)INT_MIN - 0.5 && x < (double)INT_MAX + 0.5,
|
|
||||||
wxT("argument out of supported range"));
|
|
||||||
|
|
||||||
return (int)std::lround(x);
|
|
||||||
}
|
|
||||||
#else /* C++98 */
|
#else /* C++98 */
|
||||||
|
|
||||||
#if defined(__VISUALC__) || defined(__BORLANDC__)
|
#if defined(__VISUALC__) || defined(__BORLANDC__)
|
||||||
@@ -112,18 +104,6 @@
|
|||||||
#define wxIsNaN(x) ((x) != (x))
|
#define wxIsNaN(x) ((x) != (x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline int wxRound(double x)
|
|
||||||
{
|
|
||||||
wxASSERT_MSG(x > (double)INT_MIN - 0.5 && x < (double)INT_MAX + 0.5,
|
|
||||||
wxT("argument out of supported range"));
|
|
||||||
|
|
||||||
#if defined(HAVE_ROUND) || wxCHECK_VISUALC_VERSION(12)
|
|
||||||
return int(lround(x));
|
|
||||||
#else
|
|
||||||
return (int)(x < 0 ? x - 0.5 : x + 0.5);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* C++11/C++98 */
|
#endif /* C++11/C++98 */
|
||||||
|
|
||||||
#ifdef __INTELC__
|
#ifdef __INTELC__
|
||||||
@@ -154,6 +134,34 @@
|
|||||||
|
|
||||||
inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); }
|
inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); }
|
||||||
|
|
||||||
|
inline int wxRound(double x)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(x > double(INT_MIN) - 0.5 && x < double(INT_MAX) + 0.5,
|
||||||
|
"argument out of supported range");
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103
|
||||||
|
return int(std::lround(x));
|
||||||
|
#elif defined(HAVE_ROUND) || wxCHECK_VISUALC_VERSION(12)
|
||||||
|
return int(lround(x));
|
||||||
|
#else
|
||||||
|
return int(x < 0 ? x - 0.5 : x + 0.5);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int wxRound(float x)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(x > float(INT_MIN) && x < float(INT_MAX),
|
||||||
|
"argument out of supported range");
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103
|
||||||
|
return int(std::lround(x));
|
||||||
|
#elif defined(HAVE_ROUND) || wxCHECK_VISUALC_VERSION(12)
|
||||||
|
return int(lroundf(x));
|
||||||
|
#else
|
||||||
|
return int(x < 0.0f ? x - 0.5f : x + 0.5f);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Convert between degrees and radians.
|
// Convert between degrees and radians.
|
||||||
inline double wxDegToRad(double deg) { return (deg * M_PI) / 180.0; }
|
inline double wxDegToRad(double deg) { return (deg * M_PI) / 180.0; }
|
||||||
inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; }
|
inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; }
|
||||||
|
Reference in New Issue
Block a user