| 138 | } |
| 139 | |
| 140 | template<class T, class Rounding> inline |
| 141 | T pow_up(const T& x_, int pwr, Rounding& rnd) // x and pwr are positive |
| 142 | { |
| 143 | T x = x_; |
| 144 | T y = (pwr & 1) ? x_ : static_cast<T>(1); |
| 145 | pwr >>= 1; |
| 146 | while (pwr > 0) { |
| 147 | x = rnd.mul_up(x, x); |
| 148 | if (pwr & 1) y = rnd.mul_up(x, y); |
| 149 | pwr >>= 1; |
| 150 | } |
| 151 | return y; |
| 152 | } |
| 153 | |
| 154 | } // namespace detail |
| 155 | } // namespace interval_lib |