Not computes the complement of a bit array.
(d BitArray)
| 418 | |
| 419 | // Not computes the complement of a bit array. |
| 420 | func Not(d BitArray) BitArray { |
| 421 | res := d.Clone() |
| 422 | for i, w := range res.words { |
| 423 | res.words[i] = ^w |
| 424 | } |
| 425 | if res.lastBitsUsed > 0 { |
| 426 | lastWord := len(res.words) - 1 |
| 427 | res.words[lastWord] &= (^word(0) << (numBitsPerWord - res.lastBitsUsed)) |
| 428 | } |
| 429 | return res |
| 430 | } |
| 431 | |
| 432 | // And computes the logical AND of two bit arrays. |
| 433 | // The caller must ensure they have the same bit size. |