Not computes the complement of a bit array.
(d BitArray)
| 404 | |
| 405 | // Not computes the complement of a bit array. |
| 406 | func Not(d BitArray) BitArray { |
| 407 | res := d.Clone() |
| 408 | for i, w := range res.words { |
| 409 | res.words[i] = ^w |
| 410 | } |
| 411 | if res.lastBitsUsed > 0 { |
| 412 | lastWord := len(res.words) - 1 |
| 413 | res.words[lastWord] &= (^word(0) << (numBitsPerWord - res.lastBitsUsed)) |
| 414 | } |
| 415 | return res |
| 416 | } |
| 417 | |
| 418 | // And computes the logical AND of two bit arrays. |
| 419 | // The caller must ensure they have the same bit size. |