bin2dec: Converting between decimal and binary numbers

Description Usage Arguments Value See Also Examples

Description

These functions provide user-friendly interface to low-level routines b2d and d2b for converting between decimal and binary numbers.

Usage

1
2
3
4
5
6
dec2bin(dec, num = TRUE)
bin2dec(bin)
## S4 method for signature 'numeric'
bin2dec(bin)
## S4 method for signature 'character'
bin2dec(bin)

Arguments

bin

binary number as a numeric vector of 0s and 1s or a single character string containing 0s and 1s only

dec

single decimal number to be converted

num

logical, whether a numeric vector (instead of single character string) should be returned

Value

For bin2dec the decimal number representing the binary input.

For dec2bin, if num is TRUE, which is the default, the numeric vector containing the binary number. If num is FALSE then a single string containing the sequence of 0s and 1s is returned.

See Also

b2d and d2b for low-level procedures

Examples

1
2
3
4
5
bin2dec("1101")
bin2dec(c(1,1,0,1))

dec2bin(13)
dec2bin(13, FALSE)

rgraph6 documentation built on May 2, 2019, 4:50 p.m.