Return the number of bytes needed to fit the given number of bits
| 47 | |
| 48 | // Return the number of bytes needed to fit the given number of bits |
| 49 | constexpr int64_t BytesForBits(int64_t bits) { |
| 50 | // This formula avoids integer overflow on very large `bits` |
| 51 | return (bits >> 3) + ((bits & 7) != 0); |
| 52 | } |
| 53 | |
| 54 | // Returns the smallest power of two that contains v. If v is already a |
| 55 | // power of two, it is returned as is. |
no outgoing calls