19 #ifndef __libpbd_integer_division_h__
20 #define __libpbd_integer_division_h__
24 #ifndef COMPILER_INT128_SUPPORT
25 #include <boost/multiprecision/cpp_int.hpp>
29 #define PBD_IDIV_ASR(x) ((x) < 0 ? -1 : 0)
37 #define PBD_IDIV_ROUNDING(x,y) ( (y)/2 - (PBD_IDIV_ASR((x)^(y)) & (y)))
55 #ifndef COMPILER_INT128_SUPPORT
56 boost::multiprecision::int512_t bignum = v;
64 return bignum.convert_to<int64_t> ();
67 fatal <<
"arithmetic overflow in timeline math\n" <<
endmsg;
76 __int128 vn (_v * _n);
86 return(int64_t) ((vn + hd) / _d);
93 #ifndef COMPILER_INT128_SUPPORT
94 boost::multiprecision::int512_t bignum = v;
101 return bignum.convert_to<int64_t> ();
104 fatal <<
"arithmetic overflow in timeline math\n" <<
endmsg;
120 return(int64_t) ((_v * _n) / _d);
T int_div_round(T x, T y)
#define PBD_IDIV_ROUNDING(x, y)
int64_t muldiv_floor(int64_t v, int64_t n, int64_t d)
int64_t muldiv_round(int64_t v, int64_t n, int64_t d)
std::ostream & endmsg(std::ostream &ostr)