Sha256: 8c54c845ce8bcd8488c4de1ad6d8b7eac48a7594ac5a7d9c5ba439f77a7212a5

Contents?: true

Size: 752 Bytes

Versions: 2

Compression:

Stored size: 752 Bytes

Contents

## Integer#bit

    require 'facets/integer/bitmask'

    0.bit(0).assert == 1
    0.bit(1).assert == 2
    0.bit(2).assert == 4
    0.bit(3).assert == 8

Negate

    1.bit(~0).assert == 0
    2.bit(~1).assert == 0
    4.bit(~2).assert == 0
    8.bit(~3).assert == 0

## Integer#bit?

    a = 8
    assert(! a.bit?(0))
    assert(! a.bit?(1))
    assert(! a.bit?(2))
    assert(  a.bit?(3))
    assert(! a.bit?(4))
    assert(! a.bit?(5))

## Integer#bit_clear

    1.bit_clear(0).assert == 0
    2.bit_clear(1).assert == 0
    4.bit_clear(2).assert == 0
    8.bit_clear(3).assert == 0

## Integer#bitmask

    a =  1
    m = Bit(4)
    a = a.bitmask(m)
    a.assert == 17
    assert( a.bitmask?(m) )

## Kernel#Bit

    n = Bit(4)
    n.assert == 16

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 demo/core/integer/bitmask.md
facets-3.1.0 demo/core/integer/bitmask.md