DecToBin {MiscMath} | R Documentation |
Convert Decimal to Binary
Description
Convert a given decimal constant in the interval (0, 1) to the corresponding binary representation.
Usage
DecToBin(x, m = 32, format = "character")
Arguments
x |
a numeric vector of values in the interval (0, 1) |
m |
a numeric constant specifying the number of binary digits to use in the output |
format |
a character string constant specifying the form of the output |
Details
Default format is as a character string. Alternatives are plain
which prints
results to the device, and vector
which output a binary vector.
Value
a vector containing the binary representation
Examples
x <- c(.81, .57, .333)
DecToBin(x) # character output
DecToBin(x, format="vector") # binary vector output
DecToBin(x, format="plain")
[Package MiscMath version 1.1 Index]