33 #if defined(HAVE_LROUND)
35 #elif defined(HAVE_RINT)
38 return (
long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
48 #if defined(HAVE_LLROUND)
49 return (int64_t)llround(d);
50 #elif defined(HAVE_RINT)
51 return (int64_t)rint(d);
53 return (int64_t)(d > 0 ? d + 0.5 : ceil(d - 0.5));
65 #if (defined(MINGW_ANY)||defined(__FreeBSD__)) && GCC_VERSION >= 409
76 #define PROBLEMATIC_FLOAT_CONVERSION_WARNING
77 DISABLE_GCC_WARNING(
"-Wfloat-conversion")
84 #if defined(__clang__)
85 #if __has_warning("-Wdouble-promotion")
86 #define PROBLEMATIC_DOUBLE_PROMOTION_WARNING
87 DISABLE_GCC_WARNING(
"-Wdouble-promotion")
104 frexp(number, &exponent);
110 if (isfinite(number) && exponent <= 63) {
111 return (int64_t)number;
115 return signbit(number) ? INT64_MIN : INT64_MAX;
117 #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
118 ENABLE_GCC_WARNING(
"-Wdouble-promotion")
120 #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
121 ENABLE_GCC_WARNING(
"-Wfloat-conversion")
130 #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
131 DISABLE_GCC_WARNING(
"-Wfloat-conversion")
133 #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
134 DISABLE_GCC_WARNING(
"-Wdouble-promotion")
137 #ifdef PROBLEMATIC_DOUBLE_PROMOTION_WARNING
138 ENABLE_GCC_WARNING(
"-Wdouble-promotion")
140 #ifdef PROBLEMATIC_FLOAT_CONVERSION_WARNING
141 ENABLE_GCC_WARNING(
"-Wfloat-conversion")
double tor_mathlog(double d)
long tor_lround(double d)
int64_t clamp_double_to_int64(double number)
int64_t tor_llround(double d)