SizesForBitLen computes the number of words and last bits used for the requested bit array size.
(bitLen uint)
| 324 | // SizesForBitLen computes the number of words and last bits used for |
| 325 | // the requested bit array size. |
| 326 | func SizesForBitLen(bitLen uint) (uint, uint64) { |
| 327 | // This computes ceil(bitLen / numBitsPerWord). |
| 328 | numWords := (bitLen + numBitsPerWord - 1) / numBitsPerWord |
| 329 | lastBitsUsed := uint64(bitLen % numBitsPerWord) |
| 330 | if lastBitsUsed == 0 { |
| 331 | lastBitsUsed = numBitsPerWord |
| 332 | } |
| 333 | return numWords, lastBitsUsed |
| 334 | } |
| 335 | |
| 336 | // Parse parses a bit array from the specified string. |
| 337 | func Parse(s string) (res BitArray, err error) { |
no outgoing calls
no test coverage detected