7#include "dlinear/util/math.h"
12#include "dlinear/util/exception.h"
13#include "dlinear/util/logging.h"
18 if (!((std::numeric_limits<int>::lowest() <= v) && (v <= std::numeric_limits<int>::max()))) {
22 return std::modf(v, &intpart) == 0.0;
27 if (!((std::numeric_limits<int>::lowest() <= v) && (v <= std::numeric_limits<int>::max()))) {
35 if (std::numeric_limits<int>::min() <= v && v <= std::numeric_limits<int>::max())
return static_cast<int>(v);
36 DLINEAR_RUNTIME_ERROR_FMT(
"Fail to convert a std::int64_t value {} to int", v);
40 constexpr std::int64_t m{1UL <<
static_cast<unsigned>(std::numeric_limits<double>::digits)};
41 if (-m <= v && v <= m)
return static_cast<double>(v);
42 DLINEAR_RUNTIME_ERROR_FMT(
"Fail to convert a std::int64_t value {} to double", v);
Global namespace for the dlinear library.
int ConvertInt64ToInt(const std::int64_t v)
Convert v of int64_t to int.
double ConvertInt64ToDouble(const std::int64_t v)
Convert v of int64_t to double.
bool IsInteger(const double v)
Returns true if v is represented by int.
mpq_class ConvertInt64ToRational(std::int64_t v)
Convert v of int64_t to rational.