Description Usage Arguments Details Author(s) See Also Examples
Functions for computing binary to decimal conversion of numbers and vice versa.
1 2 | decimal2binary(x, length)
binary2decimal(x)
|
x |
input value. |
length |
an optional value giving the length of binary string to return. |
decimal2binary
converts a numerical value (which is forced to be an integer) to a binary representation, i.e. a vector of 0s and 1s. For real numerical values see the example below.
binary2binary
converts a binary value, i.e. a vector of 0s and 1s, to a decimal representation.
Luca Scrucca
1 2 3 4 5 6 7 8 9 10 | # for integer values
dval <- 12
(bval <- decimal2binary(dval))
binary2decimal(bval)
# for real values
dval <- 12.456
# use
(bval <- decimal2binary(dval*1000))
binary2decimal(bval)/1000
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.