bits: Set and get bits from binary masks.

bitsR Documentation

Set and get bits from binary masks.

Description

Utility functions to access bits from numeric values, for the efficient storage of spatial masks.

Usage

bits(object, bit)

bits(object, bit) <-  value

Arguments

object

a numeric value

bit

the desired bit

value

logical value to set bit to

Details

R uses 32-bit integers, so we can (easily) access 31 binary matrices in each numeric matrix. This is very useful for storing long time-series of spatial masks, required for track-location estimation from archival tags.

Value

A numeric object with the given bit set, or a logical value designating the status of the given bit.

Note

The 32nd bit is harder to access, so we ignore it.

Author(s)

Michael D. Sumner

See Also

See Also get.mask for a higher level access of a mask object

Examples

a <- 1L
bits(a, 0)  ## 1
bits(a, 2) <- 1
a   # 5


Trackage/tripEstimation documentation built on April 24, 2023, 6:57 p.m.