Learn R Programming

SoDA (version 1.0-6.1)

binaryRep: Generate Binary Representation in R

Description

Functions to generate a binary representation from numeric data, as an example of vectorizing computations.

Usage

binaryRep(data, m = .Machine$double.digits)

binaryRepA(m)

binaryRepBits(data)

binaryRepPowers(n, m)

Arguments

data

numeric data

m

number of bits in mantissa

n

range for powers

Value

The main function, binaryRep returns an object from class "binaryRep" providing the components of the representation of data, as well as the original data itself.

The other functions are helper functions; see the examples in the book.

Class <code>binaryRep</code>

The object returned

original:

The original data, of class "numeric"

sign, exponent:

Objects of class "integer" for the sign and exponent.

bits:

Object of class "raw" for the significand.

Examples

Run this code
# NOT RUN {
binaryRep(c(.1, .25, 1/3))
# }

Run the code above in your browser using DataLab