Main Content

Convert decimal integer to its binary representation

`binStr = dec2bin(`

returns the binary, or
base-2, representation of the decimal integer `D`

)`D`

. The output argument
`binStr`

is a character vector that represents binary digits using the
characters `0`

and `1`

.

If `D`

is a numeric vector, matrix, or multidimensional array, then
`binStr`

is a two-dimensional character array. Each row of
`binStr`

represents an element of `D`

.

The output of

`dec2bin`

is the same whether your computer stores values in memory using big-endian or little-endian format. For more information on these formats, see Endianness.