binary2decimal: Binary encoding of decimal numbers and vice versa.
Description
Functions for computing binary to decimal conversion of numbers and vice versa.
Usage
decimal2binary(x, length)
binary2decimal(x)
Arguments
x
input value.
length
an optional value giving the length of binary string to return.
Author
Luca Scrucca
Details
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.
binary2decimal converts a binary value, i.e. a vector of 0s and 1s, to a decimal representation.