| 243 | // Check whether an N-bit two's-complement representation can hold value. |
| 244 | template <typename T> |
| 245 | inline bool IsInt(size_t N, T value) { |
| 246 | if (N == BitSizeOf<T>()) { |
| 247 | return true; |
| 248 | } else { |
| 249 | CHECK_LT(0u, N); |
| 250 | CHECK_LT(N, BitSizeOf<T>()); |
| 251 | T limit = static_cast<T>(1) << (N - 1u); |
| 252 | return (-limit <= value) && (value < limit); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | template <typename T> |
| 257 | constexpr T GetIntLimit(size_t bits) { |
nothing calls this directly
no outgoing calls
no test coverage detected