| 150 | } |
| 151 | |
| 152 | inline int |
| 153 | PowOps::cnroot(int x) const { |
| 154 | if (x < 2) |
| 155 | return x; |
| 156 | /* |
| 157 | * We look for u such that: (u-1)^n < x <= u^n |
| 158 | */ |
| 159 | long long int l = 1; |
| 160 | long long int u = x; |
| 161 | do { |
| 162 | long long int m = (l + u) >> 1; |
| 163 | if (powle(m,x)) l=m; else u=m; |
| 164 | } while (l+1 < u); |
| 165 | assert((pow(u-1) < x) && (x <= pow(u))); |
| 166 | return static_cast<int>(u); |
| 167 | } |
| 168 | |
| 169 | |
| 170 |
no test coverage detected