Description Usage Arguments Details Value See Also Examples
Converts an integer (Base10) to a binary (Base2) number. It also converts a logical vector to a binary (Base2) number (see examples).
1 |
x |
integer or logical vector. |
signed |
TRUE or FALSE. Unsigned by default. (two's complement) |
littleEndian |
if TRUE. Big Endian if FALSE. |
size |
in Byte. Needed if signed is set. (by default 2 Byte) |
n |
in Bit. Can be set if unsigned is set to TRUE. (by default 0 Bit = auto) |
logic |
If set to TRUE, x is expected as logical vector. |
The binary number is represented by a logical vector. The bit order usually follows the same endianess as the byte order. No floating-point support. If logic is set to TRUE an integer vector is intepreted as a logical vector (>0 becomes TRUE and 0 becomes FALSE)
Little Endian (LSB) —> (MSB)
Big Endian (MSB) <— (LSB)
Auto switch to signed if num < 0.
a vector of class binary.
is.binary and binary
1 2 3 4 5 6 7 8 9 10 | as.binary(0xAF)
as.binary(42)
as.binary(42, littleEndian=TRUE)
as.binary(c(0xAF, 0xBF, 0xFF))
as.binary(c(2,4,8,16,32), signed=TRUE, size=1)
as.binary(-1, signed=TRUE, size=1)
as.binary(1:7, n=3)
as.binary(sample(2^8,3),n=8)
as.binary(c(1,1,0), signed=TRUE, logic=TRUE)
as.binary(c(TRUE,TRUE,FALSE), logic=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.