bitstring {utils}R Documentation

Bit-level representation of R atomic vectors

Description

This is a simple user-friendly wrapper for intToBits etc., inspired by the Julia function bitstring.

Usage


bitstring(x)

## S3 method for class 'raw'
bitstring(x)
## S3 method for class 'integer'
bitstring(x)
## S3 method for class 'numeric'
bitstring(x)
## Default S3 method:
bitstring(x)

## S3 method for class 'bitstring'
format(x, sep = " ", ...)
## S3 method for class 'bitstring'
print(x, ...)

Arguments

x

For bitsring(), an atomic R vector. Currently integer, numeric, and raw vectors are supported.

For the format and print methods, an object of class "bitstring".

sep

character string to be used as visual breakpoints between sign bit, mantissa, and exponent, as appropriate.

...

additional arguments for compatibility; ignored.

Value

An object of class "bitstring" which stores the bit patterns of the underlying vector as character strings, along with type information.

format.bitstring formats a bitstring object for user-friendly display.

Examples


x <- bitstring(pi^((-3):3))
x
print(x, sep = "-")

bitstring(seq(-3, 3))
bitstring(seq(-3, 3) |> as.numeric())
bitstring(c(NA_real_, NaN, Inf, -Inf))
bitstring(NA_integer_)
bitstring(charToRaw("bits"))


[Package utils version 4.6.0 Index]